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

strncpy calls #18

Closed
gt1 opened this issue Jul 25, 2019 · 1 comment
Closed

strncpy calls #18

gt1 opened this issue Jul 25, 2019 · 1 comment

Comments

@gt1
Copy link
Contributor

gt1 commented Jul 25, 2019

I see a few warnings like

In file included from /usr/include/string.h:630, from cram_io.c:60:
In function ‘full_path’, inlined from ‘cram_write_SAM_hdr’ at cram_io.c:4622:3:
cram_io.c:4564:6: warning: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
 4564 |      strncpy(out, in, PATH_MAX);

when compiling io_lib with gcc 9.1.0. The complaint here is that out is an array of size PATH_MAX, so there is no space for putting an extra 0 in case in actually has PATH_MAX non null symbols. Maybe making sure there is a terminator in all cases would be a good idea (in terms of security).

@jkbonfield
Copy link
Owner

How very picky, given the adjacent line:

        strncpy(out, in, PATH_MAX);
        out[PATH_MAX-1] = 0;

I guess I need to use PATH_MAX-1 to silence the whine. I'm building gcc9 so I can explore this first though.

Thanks for the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants