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

gcc9 warns about s_sysinfo size #13

Closed
timp87 opened this issue Nov 18, 2019 · 6 comments
Closed

gcc9 warns about s_sysinfo size #13

timp87 opened this issue Nov 18, 2019 · 6 comments

Comments

@timp87
Copy link

timp87 commented Nov 18, 2019

This problem appears again:

util.c: In function 'get_sysinfo':
util.c:1082:61: error: ' ' directive output may be truncated writing 1 byte into a region of size between 0 and 255 [-Werror=format-truncation=]
 1082 |         (void) snprintf (s_sysinfo, sizeof(s_sysinfo)-1, "%s %s %s",
      |                                                             ^
util.c:1082:16: note: 'snprintf' output between 3 and 768 bytes into a destination of size 255
 1082 |         (void) snprintf (s_sysinfo, sizeof(s_sysinfo)-1, "%s %s %s",
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1083 |             uts.sysname, uts.release, uts.machine);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

s_sysinfo was extended to 256 before in 2cdb00f, but this is not enough for gcc9.

I suppose this should be reworked somehow.

Also seems like snprintf() always null terminates the buffer. Is such code really needed?
https://github.com/pcherenkov/udpxy/blob/master/chipmunk/util.c#L1081

@pcherenkov
Copy link
Owner

pcherenkov commented Nov 18, 2019

What distro/repo are you using that has gcc-9?

@timp87
Copy link
Author

timp87 commented Nov 18, 2019

Oh, sorry. This is Freebsd 12.1

@pcherenkov
Copy link
Owner

I just pushed out the new sysinfo-gcc9 branch w/o testing on gcc9, please try it out and let me know if it works. s_sysinfo is extended to 1024, snprintf() taken care of, too.

@timp87
Copy link
Author

timp87 commented Nov 18, 2019

It compiled and seems working

@pcherenkov
Copy link
Owner

ok then

@timp87
Copy link
Author

timp87 commented Nov 18, 2019

let's close this issue

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