This should fix the overflows that gcc-4.5 warns about
--- proto_xboard.cc.old 2010-11-03 14:20:54.000000000 +0100
+++ proto_xboard.cc 2010-11-03 14:22:00.000000000 +0100
@@ -1084,7 +1084,7 @@
snprintf(EngineCommandLine,512,"crafty bookpath=%s logpath=%s tbpath=%s",
BookPath,LogPath,LogPath);
if (!global.env.Home.empty())
- snprintf(EngineRunDir,512,"%s/.eboard/craftylog",global.env.Home.c_str());
+ snprintf(EngineRunDir, sizeof(EngineRunDir), "%s/.eboard/craftylog", global.env.Home.c_str());
else
strcpy(EngineRunDir,"/tmp");
--- util.cc.old 2010-11-03 14:27:13.000000000 +0100
+++ util.cc 2010-11-03 14:27:59.000000000 +0100
@@ -783,7 +783,7 @@
int i,n;
char cmd[1024];
- n = snprintf(tmpfile,1024,"/tmp/eb%d-%s",(int) getpid(), origfile);
+ n = snprintf(tmpfile, sizeof(tmpfile), "/tmp/eb%d-%s", (int) getpid(), origfile);
if (n >= 1024) {
failure = 1;
merged this in this eboard version (1)
though I have a newer gcc I had these warnings (2) during building
after merging this patch they are gone
BUT: this definitely needs more testing...
my system info is: (3)
(1) https://gitorious.org/eboard/pages/Changes
(2) g++ -O6 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -c proto_xboard.cc -o proto_xboard.o
In file included from /usr/include/stdio.h:934:0,
from proto_xboard.cc:27:
In function ‘int snprintf(char*, size_t, const char*, ...)’,
inlined from ‘virtual void CraftyProtocol::readDialog()’ at proto_xboard.cc:1087:78:
/usr/include/i386-linux-gnu/bits/stdio2.h:66:44: warning: call to int __builtin___snprintf_chk(char*, unsigned int, int, unsigned int, const char*, ...) will always overflow destination buffer [enabled by default]
g++ -O6 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -c util.cc -o util.o
In file included from /usr/include/stdio.h:934:0,
from util.h:31,
from util.cc:27:
In function ‘int snprintf(char*, size_t, const char*, ...)’,
inlined from ‘void zifstream::copen()’ at util.cc:786:69:
/usr/include/i386-linux-gnu/bits/stdio2.h:66:44: warning: call to int __builtin___snprintf_chk(char*, unsigned int, int, unsigned int, const char*, ...) will always overflow destination buffer [enabled by default]
(3) Ubuntu 12.04 32bit live cd
=== START DEBUG INFO ===
GTK+ version 2.24.10
GCC says: c++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Perl says: This is perl 5, version 14, subversion 2 (v5.14.2) built for i686-linux-gnu-thread-multi-64int
expect says: expect version 5.45
kernel info: Linux 3.2.0-23-generic-pae i686
FICS timeseal:
timeseal.Linux Not Found (errno 2)
=== END DEBUG INFO ===