Xen Test Framework
tests
xsa-122
main.c
Go to the documentation of this file.
1
23
#include <xtf.h>
24
25
const
char
test_title
[] =
"XSA-122 PoC"
;
26
27
/*
28
* Check a buffer of a specified size for non-NUL bytes following the string
29
* NUL terminator.
30
*/
31
static
void
check_buffer
(
const
char
*ref,
const
char
*buf,
size_t
buf_sz)
32
{
33
unsigned
int
i;
34
size_t
str_len =
strnlen
(buf, buf_sz);
35
36
if
( str_len == buf_sz )
37
return
xtf_warning
(
" %s string not NUL terminated\n"
, ref);
38
39
else
if
( str_len == buf_sz - 1 )
40
return
;
/* No trailing space after data. */
41
42
for
( i = str_len + 1; i < buf_sz && buf[i] ==
'\0'
; ++i )
43
;
/* No action. */
44
45
if
( i != buf_sz )
46
xtf_failure
(
" '%s' has leaked stack at index %u\n"
, ref, i);
47
}
48
49
void
test_main
(
void
)
50
{
51
long
rc;
52
53
printk
(
"XENVER_extraversion:\n"
);
54
{
55
xen_extraversion_t
extra;
56
57
memset
(&extra, 0,
sizeof
(extra));
58
59
rc =
hypercall_xen_version
(
XENVER_extraversion
, extra);
60
if
( rc < 0 )
61
return
xtf_failure
(
"XENVER_extraversion error %ld\n"
, rc);
62
63
printk
(
" Got '%s'\n"
, extra);
64
check_buffer
(
"extraversion"
, extra,
sizeof
(extra));
65
}
66
67
printk
(
"XENVER_compile_info:\n"
);
68
{
69
xen_compile_info_t
ci;
70
71
memset
(&ci, 0,
sizeof
(ci));
72
73
rc =
hypercall_xen_version
(
XENVER_compile_info
, &ci);
74
if
( rc < 0 )
75
return
xtf_failure
(
"XENVER_compile_info error %ld\n"
, rc);
76
77
printk
(
" Got '%s'\n"
78
" '%s'\n"
79
" '%s'\n"
80
" '%s'\n"
,
81
ci.
compiler
, ci.
compile_by
, ci.
compile_domain
, ci.
compile_date
);
82
83
check_buffer
(
"compiler"
, ci.
compiler
,
sizeof
(ci.
compiler
));
84
check_buffer
(
"compile_by"
, ci.
compile_by
,
sizeof
(ci.
compile_by
));
85
check_buffer
(
"compile_domain"
, ci.
compile_domain
,
sizeof
(ci.
compile_domain
));
86
check_buffer
(
"compile_date"
, ci.
compile_date
,
sizeof
(ci.
compile_date
));
87
}
88
89
printk
(
"XENVER_changeset:\n"
);
90
{
91
xen_changeset_info_t
ci;
92
93
memset
(&ci, 0,
sizeof
(ci));
94
95
rc =
hypercall_xen_version
(
XENVER_changeset
, &ci);
96
if
( rc < 0 )
97
return
xtf_failure
(
"XENVER_changeset error %ld\n"
, rc);
98
99
printk
(
" Got '%s'\n"
, ci);
100
check_buffer
(
"changeset_info"
, ci,
sizeof
(ci));
101
}
102
103
xtf_success
(
NULL
);
104
}
105
106
/*
107
* Local variables:
108
* mode: C
109
* c-file-style: "BSD"
110
* c-basic-offset: 4
111
* tab-width: 4
112
* indent-tabs-mode: nil
113
* End:
114
*/
printk
void printk(const char *fmt,...)
Definition:
console.c:134
test_main
void test_main(void)
To be implemented by each test, as its entry point.
Definition:
main.c:110
test_title
const char test_title[]
The title of the test.
Definition:
main.c:24
hypercall_xen_version
static long hypercall_xen_version(unsigned int cmd, void *arg)
Definition:
hypercall.h:126
memset
#define memset(d, c, n)
Definition:
libc.h:33
xtf_failure
void xtf_failure(const char *fmt,...)
Report a test failure.
Definition:
report.c:94
xtf_warning
void xtf_warning(const char *fmt,...)
Report a test warning.
Definition:
report.c:52
xtf_success
void xtf_success(const char *fmt,...)
Report test success.
Definition:
report.c:38
NULL
#define NULL
Definition:
stddef.h:12
strnlen
size_t strnlen(const char *str, size_t max)
Definition:
string.c:13
xen_compile_info
Definition:
version.h:16
xen_compile_info::compiler
char compiler[64]
Definition:
version.h:17
xen_compile_info::compile_date
char compile_date[32]
Definition:
version.h:20
xen_compile_info::compile_domain
char compile_domain[32]
Definition:
version.h:19
xen_compile_info::compile_by
char compile_by[16]
Definition:
version.h:18
XENVER_compile_info
#define XENVER_compile_info
Definition:
version.h:15
xen_extraversion_t
char xen_extraversion_t[16]
Definition:
version.h:12
XENVER_extraversion
#define XENVER_extraversion
Definition:
version.h:11
xen_changeset_info_t
char xen_changeset_info_t[64]
Definition:
version.h:25
XENVER_changeset
#define XENVER_changeset
Definition:
version.h:24
check_buffer
static void check_buffer(const char *ref, const char *buf, size_t buf_sz)
Definition:
main.c:31
Generated by
1.9.4