[all-commits] [llvm/llvm-project] b03c8c: libc: strlcpy/strlcat shouldn't bzero the rest of ...
George Burgess IV via All-commits
all-commits at lists.llvm.org
Wed Oct 30 12:28:54 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b03c8c4fdda6e58cb1afe3aa90bf9f2df08a7970
https://github.com/llvm/llvm-project/commit/b03c8c4fdda6e58cb1afe3aa90bf9f2df08a7970
Author: George Burgess IV <george.burgess.iv at gmail.com>
Date: 2024-10-30 (Wed, 30 Oct 2024)
Changed paths:
M libc/src/string/string_utils.h
M libc/test/src/string/strlcat_test.cpp
M libc/test/src/string/strlcpy_test.cpp
Log Message:
-----------
libc: strlcpy/strlcat shouldn't bzero the rest of `buf` (#114259)
When running Bionic's testsuite over llvm-libc, tests broke because
e.g.,
```
const char *str = "abc";
char buf[7]{"111111"};
strlcpy(buf, str, 7);
ASSERT_EQ(buf, {'1', '1', '1', '\0', '\0', '\0', '\0'});
```
On my machine (Debian w/ glibc and clang-16), a `printf` loop over `buf`
gets unrolled into a series of const `printf` at compile-time:
```
printf("%d\n", '1');
printf("%d\n", '1');
printf("%d\n", '1');
printf("%d\n", 0);
printf("%d\n", '1');
printf("%d\n", '1');
printf("%d\n", 0);
```
Seems best to match existing precedent here.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list