cosmopolitan/third_party
Gabriel Ravier e3d28de8a6
Fix UB in gdtoa hexadecimal float scanf and strtod (#1288)
When reading hexadecimal floats, cosmopolitan would previously sometimes
print a number of warnings relating to undefined behavior on left shift:

third_party/gdtoa/gethex.c:172: ubsan warning: signed left shift changed
sign bit or overflowed 12 'int' 28 'int' is undefined behavior

This is because gdtoa assumes left shifts are safe when overflow happens
even on signed integers - this is false: the C standard considers it UB.
This is easy to fix, by simply casting the shifted value to unsigned, as
doing so does not change the value or the semantics of the left shifting
(except for avoiding the undefined behavior, as the C standard specifies
that unsigned overflow yields wraparound, avoiding undefined behaviour).

This commit does this, and adds a testcase that previously triggered UB.
(this also adds test macros to test for exact float equality, instead of
the existing {EXPECT,ASSERT}_FLOAT_EQ macros which only tests inputs for
being "almost equal" (with a significant epsilon) whereas exact equality
makes more sense for certain things such as reading floats from strings,
and modifies other testcases for sscanf/fscanf of floats to utilize it).
2024-09-14 17:11:04 -07:00
..
aarch64 Release Cosmopolitan v3.8.0 2024-08-30 20:14:07 -07:00
argon2 Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
awk Release Cosmopolitan v3.8.0 2024-08-30 20:14:07 -07:00
bzip2 Release Cosmopolitan v3.6.0 2024-07-23 03:28:19 -07:00
chibicc Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
compiler_rt Implement more bf16/fp16 compiler runtimes 2024-09-13 05:06:34 -07:00
ctags Fix ctype.h and wctype.h 2024-07-21 15:54:17 -07:00
dlmalloc Make recursive mutexes faster 2024-09-10 00:08:59 -07:00
double-conversion Release Cosmopolitan v3.8.0 2024-08-30 20:14:07 -07:00
finger Fix ctype.h and wctype.h 2024-07-21 15:54:17 -07:00
gdtoa Fix UB in gdtoa hexadecimal float scanf and strtod (#1288) 2024-09-14 17:11:04 -07:00
getopt Delete ASAN 2024-06-22 05:45:49 -07:00
hiredis Fix ctype.h and wctype.h 2024-07-21 15:54:17 -07:00
intel Release Cosmopolitan v3.8.0 2024-08-30 20:14:07 -07:00
less Update Musl Libc code 2024-07-30 22:51:29 -07:00
libcxx Add missing pragma 2024-08-16 21:49:28 -07:00
libcxxabi Fix some static analysis issues 2024-07-27 09:16:54 -07:00
libunwind Release Cosmopolitan v3.8.0 2024-08-30 20:14:07 -07:00
linenoise Make improvements 2024-09-01 01:27:47 -07:00
lua Fix default open mode in redbean unix.open() 2024-09-14 00:10:21 -07:00
lz4cli Implement proper time zone support 2024-05-04 23:06:37 -07:00
make Release Cosmopolitan v3.6.0 2024-07-23 03:28:19 -07:00
maxmind Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
mbedtls Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
musl Make vim startup faster 2024-09-11 00:52:34 -07:00
ncurses Release Cosmopolitan v3.6.0 2024-07-23 03:28:19 -07:00
nsync Rewrite Windows poll() 2024-09-10 20:04:02 -07:00
openmp Introduce pthread_condattr_setclock() 2024-09-02 23:45:42 -07:00
pcre Update Musl Libc code 2024-07-30 22:51:29 -07:00
puff Delete ASAN 2024-06-22 05:45:49 -07:00
python Upgrade pl_mpeg 2024-09-06 19:10:34 -07:00
qemu more modeline errata (#1019) 2023-12-16 23:07:10 -05:00
readline Fix --ftrace on Windows 2024-01-01 00:00:42 -08:00
regex Update Musl Libc code 2024-07-30 22:51:29 -07:00
sed Update Musl Libc code 2024-07-30 22:51:29 -07:00
smallz4 Release Cosmopolitan v3.8.0 2024-08-30 20:14:07 -07:00
sqlite3 Move LoadZipArgs() to cosmo.h 2024-08-17 12:06:27 -07:00
stb Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
tidy Fix MODE=optlinux and MODE=tiny builds 2024-07-23 04:04:19 -07:00
tr Make improvements 2024-09-01 01:27:47 -07:00
tree Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
tz Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
unzip Update Musl Libc code 2024-07-30 22:51:29 -07:00
vqsort more modeline errata (#1019) 2023-12-16 23:07:10 -05:00
xed Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
xxhash Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zip Change InfoZIP to not auto-append .zip to pathname 2024-08-17 06:45:23 -07:00
zlib Release Cosmopolitan v3.6.0 2024-07-23 03:28:19 -07:00
zstd Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
.clang-format Reduce header complexity 2023-11-28 14:39:42 -08:00
BUILD.mk Release Cosmopolitan v3.6.0 2024-07-23 03:28:19 -07:00