mirror of git://sourceware.org/git/glibc.git
stdlib: Adapt tst-environ to ubsan
The test explicits checks for passing a null argument to a function with argument nonnull attribute.
This commit is contained in:
parent
afe9efb47c
commit
ba3e3ae80b
|
|
@ -26,6 +26,24 @@
|
||||||
|
|
||||||
char putenv_val[100] = VAR "=some longer value";
|
char putenv_val[100] = VAR "=some longer value";
|
||||||
|
|
||||||
|
static int
|
||||||
|
__attribute_disable_ubsan__
|
||||||
|
check_null_argument (void)
|
||||||
|
{
|
||||||
|
/* This deliberately tests supplying a null pointer to a function whose
|
||||||
|
argument is marked __attribute__ ((nonnull)). */
|
||||||
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
|
DIAG_IGNORE_NEEDS_COMMENT(5, "-Wnonnull");
|
||||||
|
errno = 0;
|
||||||
|
if (unsetenv (NULL) >= 0 || errno != EINVAL)
|
||||||
|
{
|
||||||
|
puts ("unsetenv #1 failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
|
@ -189,17 +207,7 @@ do_test (void)
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This deliberately tests supplying a null pointer to a function whose
|
result = check_null_argument ();
|
||||||
argument is marked __attribute__ ((nonnull)). */
|
|
||||||
DIAG_PUSH_NEEDS_COMMENT;
|
|
||||||
DIAG_IGNORE_NEEDS_COMMENT(5, "-Wnonnull");
|
|
||||||
errno = 0;
|
|
||||||
if (unsetenv (NULL) >= 0 || errno != EINVAL)
|
|
||||||
{
|
|
||||||
puts ("unsetenv #1 failed");
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
DIAG_POP_NEEDS_COMMENT;
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (unsetenv ("") >= 0 || errno != EINVAL)
|
if (unsetenv ("") >= 0 || errno != EINVAL)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue