games-strategy/galaxyhack: Build with -Wformat-security. Bug #57069
authorTupone Alfredo <tupone@gentoo.org>
Mon, 4 Jan 2016 15:01:23 +0000 (16:01 +0100)
committerTupone Alfredo <tupone@gentoo.org>
Mon, 4 Jan 2016 15:02:00 +0000 (16:02 +0100)
Package-Manager: portage-2.2.24

games-strategy/galaxyhack/files/galaxyhack-1.74-format.patch [new file with mode: 0644]
games-strategy/galaxyhack/galaxyhack-1.74.ebuild

diff --git a/games-strategy/galaxyhack/files/galaxyhack-1.74-format.patch b/games-strategy/galaxyhack/files/galaxyhack-1.74-format.patch
new file mode 100644 (file)
index 0000000..4bd9e8f
--- /dev/null
@@ -0,0 +1,64 @@
+--- JSDL.cpp.old       2016-01-04 10:42:56.404316856 +0100
++++ JSDL.cpp   2016-01-04 10:51:16.744255312 +0100
+@@ -47,14 +47,14 @@
+       if (!globalSettings.batch) {\r
+               if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO) == -1) {\r
+                       char output[120];\r
+-                      sprintf(output, SDL_GetError());\r
++                      strcpy(output, SDL_GetError());\r
+                       throw runtime_error(output);\r
+               }\r
+               \r
+               if (!globalSettings.disableSound) {\r
+                       if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) {\r
+                               char error[120];\r
+-                              sprintf(error, SDL_GetError());\r
++                              strcpy(error, SDL_GetError());\r
+                               string errorStr = error;\r
+                               errorStr += ", continuing without initialising sound.";\r
+                               WriteLog(errorStr);\r
+@@ -81,7 +81,7 @@
+               //4096 is rather a large chunksize, should be smaller if I add sound effects\r
+               if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 4096) == -1) {\r
+                       char output[100];\r
+-                      sprintf(output, Mix_GetError());\r
++                      strcpy(output, Mix_GetError());\r
+                       throw runtime_error(output);\r
+               }\r
+       }\r
+@@ -101,7 +101,7 @@
+       if (screen == NULL) {\r
+               SDL_Quit();\r
+               char output[120];\r
+-              sprintf(output, SDL_GetError());\r
++              strcpy(output, SDL_GetError());\r
+               throw runtime_error(output);\r
+       }\r
+ }\r
+@@ -114,7 +114,7 @@
+ \r
+       if (loadingSurface == NULL) {\r
+               char output[100];\r
+-              sprintf(output, IMG_GetError());\r
++              strcpy(output, IMG_GetError());\r
+               throw runtime_error(output);\r
+       }\r
+ \r
+@@ -308,7 +308,7 @@
+ \r
+       if (!theMusic) {\r
+               char output[100];\r
+-              sprintf(output, Mix_GetError());\r
++              strcpy(output, Mix_GetError());\r
+               throw runtime_error(output);\r
+       }\r
+ }\r
+@@ -319,7 +319,7 @@
+ \r
+       if (Mix_PlayMusic(theMusic, -1) == -1) {\r
+               char output[100];\r
+-              sprintf(output, Mix_GetError());\r
++              strcpy(output, Mix_GetError());\r
+               throw runtime_error(output);\r
+       }\r
+ }\r
index a85b75536e960a14dfbb3a0eb91e30c72bc15582..f19966e986763834ee25c036f0c14c983bb045a3 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
@@ -30,6 +30,7 @@ src_prepare() {
                "${FILESDIR}"/${P}-boost.patch \
                "${FILESDIR}"/${P}-gcc43.patch \
                "${FILESDIR}"/${P}-boost-1.50.patch \
+               "${FILESDIR}"/${P}-format.patch \
                "${FILESDIR}"/${P}-gentoo.patch
        sed -i "s:@GAMES_DATADIR@:${GAMES_DATADIR}:" \
                Main.cpp || die