Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Possible strncpy truncation bugs #1

@romkatv

Description

@romkatv

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));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions