]> git.proxmox.com Git - wasi-libc.git/commit
Fix utimensat to avoid passing uninitialized values into WASI calls.
authorDan Gohman <dev@sunfishcode.online>
Tue, 24 May 2022 20:56:33 +0000 (13:56 -0700)
committerDan Gohman <dev@sunfishcode.online>
Tue, 24 May 2022 22:17:44 +0000 (15:17 -0700)
commit225b285a61c259cc5bab3df080914bf7e0128503
tree9513d845507f0fa671274e45b9cd0b16f4b7d689
parentba81b409b044f7b166cdf3db9572963b33d6c6ac
Fix utimensat to avoid passing uninitialized values into WASI calls.

Previously, utimensat would leave the mtim and/or atim timestamps
uninitialized when the `MTIM_NOW` or `ATIM_NOW` were in use, because
that means the respective timestamps are not used.

However, clang now automatically adds `noundef` to the arguments in
functions like `__wasi_path_filestat_set_times`, and there are cases
where simplifycfg can see paths where the uninitialized values are
passed to those `noundef` arguments.

To fix this, change the utimens code to zero out the timestamps when
they aren't in use, to avoid passing uninitialized arguments.
libc-bottom-half/cloudlibc/src/libc/sys/stat/stat_impl.h