mirror of git://sourceware.org/git/glibc.git
stdio-common: Fix macro parameter shadowing in scanf input specifier tests
The use of the same name for a local variable combined with passing a pointer to it to a nested macro call causes the wrong 'err' variable to be updated in 'read_real', because '&err' is only expanded at '*errp' evaluation. Consequently the variable defined in 'read_real' is set rather than one in its 'verify_input' caller as it would be the case should 'read_real' be a function, leading to invalid input such as: %a:nan:1:3:nan(: to be accepted. Address the issue by renaming the 'err' variable in 'verify_input' to 'errx', causing such input to be correctly rejected: error: ./tst-scanf-format-skeleton.c:242: input line 1: input data format error No test case added as it's a test case issue in the first place. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
1c1f5e8f6d
commit
bc5cf78543
|
|
@ -73,19 +73,19 @@
|
||||||
({ \
|
({ \
|
||||||
__label__ out; \
|
__label__ out; \
|
||||||
bool match = true; \
|
bool match = true; \
|
||||||
int err = 0; \
|
int errx = 0; \
|
||||||
type_t v; \
|
type_t v; \
|
||||||
\
|
\
|
||||||
initialize_value (v); \
|
initialize_value (v); \
|
||||||
/* Make sure it's been committed. */ \
|
/* Make sure it's been committed. */ \
|
||||||
__asm__ ("" : : : "memory"); \
|
__asm__ ("" : : : "memory"); \
|
||||||
v = read_real (&err); \
|
v = read_real (&errx); \
|
||||||
if (err < 0) \
|
if (errx < 0) \
|
||||||
goto out; \
|
goto out; \
|
||||||
match = compare_real (val, v); \
|
match = compare_real (val, v); \
|
||||||
\
|
\
|
||||||
out: \
|
out: \
|
||||||
if (err || !match) \
|
if (errx || !match) \
|
||||||
{ \
|
{ \
|
||||||
union \
|
union \
|
||||||
{ \
|
{ \
|
||||||
|
|
@ -104,7 +104,7 @@ out: \
|
||||||
printf ("'\n"); \
|
printf ("'\n"); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
*errp = err; \
|
*errp = errx; \
|
||||||
match; \
|
match; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue