cosmopolitan/test/libc
Gabriel Ravier 9a5d69c842
Fix scanf x specifier with string of 0 (#793)
The C standard states that, in the context of an x conversion
specifier given to scanf:
> Matches an optionally signed hexadecimal integer, whose format is
> the same as expected for the subject sequence of the strtoul
> function with the value 16 for the base argument.
- C standard, 7.23.6.2.11. The fscanf function

Cosmopolitan fails to do this, as 0 should be parsed as a 0 by such an
invocation of strtoul. Instead, cosmopolitan errors out as though such
input is invalid, which is wrong.

This means that a program such as this:

 #include <stdio.h>
 #undef NDEBUG
 #include <assert.h>

int main()
{
    int v = 0;
    assert(sscanf("0", "%x", &v) == 1);
}

will not run correctly on cosmpolitan, instead failing the assertion.

This patch fixes this, along with the associated GitHub issue,
https://github.com/jart/cosmopolitan/issues/778
2023-04-15 06:25:35 -07:00
..
bits Fold LIBC_BITS into LIBC_INTRIN 2022-08-11 12:13:18 -07:00
calls Add memfd fexecve zipos support (#752) 2023-03-29 18:16:46 -07:00
dns Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
fmt Fix scanf x specifier with string of 0 (#793) 2023-04-15 06:25:35 -07:00
intrin Make intrin_test go faster 2023-03-05 22:57:07 -08:00
log Add WSL to test fleet 2022-11-02 06:49:42 -07:00
mem Improve cancellations, randomness, and time 2022-11-05 23:45:32 -07:00
nexgen32e Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
release Add *NSYNC to libc/isystem 2022-09-13 01:47:12 -07:00
runtime Remove problematic test 2023-02-05 16:50:04 -08:00
sock Update tests and CPU detection for Blink 2023-01-18 00:56:09 -08:00
stdio GetZipCdir: prevent integer underflow. posix_spawn_test.c: stop attempting to load zipos from /usr/bin/ape. (#758) 2023-03-05 14:29:38 -08:00
str Fix larger than WCHAR_MAX differences in wcs{,n}cmp (#795) 2023-03-29 20:28:18 -04:00
thread Make POSIX semaphores always process shared 2023-02-23 08:07:54 -08:00
time Make fixes and improvements 2022-10-19 07:19:19 -07:00
tinymath Pay off more technical debt 2022-09-12 23:36:56 -07:00
x Greatly expand system() shell code features 2022-10-11 21:30:31 -07:00
xed Pay off more technical debt 2022-09-12 23:36:56 -07:00
zipos Add fexecve() and map O_EXEC to O_PATH on Linux 2022-10-02 09:15:46 -07:00
test.mk Don't relocate file descriptor memory 2022-09-09 16:54:28 -07:00