cosmopolitan/test/libc
Gabriel Ravier 12e07798df
Fix printf precision/field width being limited by internal buffer size (#799)
The C standard, when defining field width and precision, never gives
any limit on the values used for them (except, I believe, that they
fit within an int). In other words, if the user gives a field width of
32145 and a precision of 9218, the implementation has to handle these
values correctly. However, when such kinds of high numbers are used
with integer conversions, cosmopolitan is limited by an internal
buffer size of 144, which means precisions and field widths have to
fit within this, which violates the standard.

This means that for example, the following program:

 #include <stdio.h>
 #include <string.h>

int main()
{
    char buf2[512] = {};

    int i = snprintf(buf2, sizeof(buf2), "%.9999u", 10);
    printf("%d %zu\n", i, strlen(buf2));
}

would, instead of printing "9999 511" (the correct output), instead
print "144 144" under cosmopolitan.

This patch fixes this.
2023-04-04 14:16:34 -04: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 printf precision/field width being limited by internal buffer size (#799) 2023-04-04 14:16:34 -04: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