Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libc: strlcpy/strlcat shouldn't bzero the rest of buf #114259

Commits on Oct 30, 2024

  1. libc: strlcpy/strlcat shouldn't bzero the rest of buf

    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.
    gburgessiv committed Oct 30, 2024
    Configuration menu
    Copy the full SHA
    4b32b83 View commit details
    Browse the repository at this point in the history