romkatv / libgit2

A cross-platform, linkable library implementation of Git that you can use in your application.
https://libgit2.org/
Other
7 stars 4 forks source link

Possible strncpy truncation bugs #1

Open romkatv opened 5 years ago

romkatv commented 5 years ago

Got these warnings while compiling on Alpine Linux against musl libc:

/tmp/gitstatus/libgit2/src/refs.c: In function 'git_reference_lookup_resolved':
/tmp/gitstatus/libgit2/src/refs.c:235:4: warning: 'strncpy' specified bound 1024 equals destination size [-Wstringop-truncation]
    strncpy(scan_name, ref->target.symbolic, sizeof(scan_name));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 77%] Building C object src/CMakeFiles/git2internal.dir/streams/registry.c.o
/tmp/gitstatus/libgit2/src/refs.c: In function 'git_reference_lookup_resolved.constprop':
/tmp/gitstatus/libgit2/src/refs.c:235:4: warning: 'strncpy' specified bound 1024 equals destination size [-Wstringop-truncation]
    strncpy(scan_name, ref->target.symbolic, sizeof(scan_name));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~