GNS3 / ubridge

Bridge for UDP tunnels, Ethernet, TAP and VMnet interfaces.
GNU General Public License v3.0
115 stars 46 forks source link

Compiler warnings in iniparser.c #70

Closed ghost closed 1 year ago

ghost commented 4 years ago

Three warnings in src/iniparser/iniparser.c are shown when building ubridge, here a full log: https://ci.appveyor.com/project/gns3-build/ubridge/builds/32494335

cc -O3 -Wall -IWpdPack\Include   -c -o src/iniparser/iniparser.o src/iniparser/iniparser.c
In file included from src/iniparser/iniparser.c:10:
src/iniparser/iniparser.c: In function ‘iniparser_load’:
src/iniparser/iniparser.c:766:52: warning: array subscript has type ‘char’ [-Wchar-subscripts]
  766 |                 ((line[len]=='\n') || (isspace(line[len])))) {
      |                                                ~~~~^~~~~
src/iniparser/iniparser.c:791:32: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
  791 |             sprintf(tmp, "%s:%s", section, key);
      |                                ^
src/iniparser/iniparser.c:791:13: note: ‘sprintf’ output between 2 and 2050 bytes into a destination of size 2049
  791 |             sprintf(tmp, "%s:%s", section, key);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
grossmj commented 4 years ago

I do not see the warnings when compiling with GCC 7.5.0 on Linux.

There is an issue opened upstream regarding this: https://github.com/ndevilla/iniparser/issues/124

The fix is most likely to use snprintf()

ghost commented 4 years ago

I see these warning with gcc 8.3.0 from Debian Buster. That's also the version shipped with Ubuntu 19.04.