tanelpoder / 0xtools

0x.Tools: X-Ray vision for Linux systems
https://0x.tools
GNU General Public License v2.0
1.22k stars 99 forks source link

Problem building from source on Linux with gcc 13.2.0 #43

Closed geotro closed 5 days ago

geotro commented 6 days ago

$ make cc -Wall -I include -o bin/xcapture src/xcapture.c src/xcapture.c: In function ‘main’: src/xcapture.c:404:28: warning: ‘%03d’ directive writing between 3 and 8 bytes into a region of size 6 [-Wformat-overflow=] 404 | sprintf(usec_buf, "%03d", (int)tmnow.tv_usec/1000); // ms resolution should be ok for infrequent sampling | ^~~~ src/xcapture.c:404:27: note: directive argument in the range [-2147483, 2147483] 404 | sprintf(usec_buf, "%03d", (int)tmnow.tv_usec/1000); // ms resolution should be ok for infrequent sampling | ^~ src/xcapture.c:404:9: note: ‘sprintf’ output between 4 and 9 bytes into a destination of size 6 404 | sprintf(usec_buf, "%03d", (int)tmnow.tv_usec/1000); // ms resolution should be ok for infrequent sampling | ^~~~~~~~~~~~~~

$ cc --version cc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Looking forward to trying these tools out!

lproven commented 6 days ago

Seconded: I have the same issue, I think.

(Running on MX Linux 23.3, fully updated; gcc (Debian 12.2.0-14) 12.2.0)

lproven@thinkpad-t420-i7:~/0xtools$ make 
cc -Wall -I include -o bin/xcapture src/xcapture.c
src/xcapture.c: In function ‘main’:
src/xcapture.c:404:28: warning: ‘%03d’ directive writing between 3 and 8 bytes into a region of size 6 [-Wformat-overflow=]
  404 |         sprintf(usec_buf, "%03d", (int)tmnow.tv_usec/1000); // ms resolution should be ok for infrequent sampling
      |                            ^~~~
src/xcapture.c:404:27: note: directive argument in the range [-2147483, 2147483]
  404 |         sprintf(usec_buf, "%03d", (int)tmnow.tv_usec/1000); // ms resolution should be ok for infrequent sampling
      |                           ^~~~~~
src/xcapture.c:404:9: note: ‘sprintf’ output between 4 and 9 bytes into a destination of size 6
  404 |         sprintf(usec_buf, "%03d", (int)tmnow.tv_usec/1000); // ms resolution should be ok for infrequent sampling
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tanelpoder commented 6 days ago

Yes I noticed these warnings when I compiled the (/proc-sampling) xcapture v1 on a newer distro with a newer gcc (gcc on Ubuntu 24.04 gives the the warning, on 22.04 or RHEL8/9 I didn't see it). These are warnings, the make/compile still succeeds.

I'll take a look and improve this.

tanelpoder commented 5 days ago

ok, fixed:

https://github.com/tanelpoder/0xtools/commit/2ea05465c4436ae2b860ed6af0efbc8a6c7af0a5