pkgsrc/games/xboing/patches/patch-ad
snj 8494207f32 strcpy and sprintf are evil, don't use them. Inspired by similar changes
in Debian.  This fixes several locally exploitable vulnerabilities.
2004-02-28 18:36:38 +00:00

56 lines
1.6 KiB
Text

$NetBSD: patch-ad,v 1.2 2004/02/28 18:36:38 snj Exp $
--- highscore.c.orig 1996-11-21 17:28:46.000000000 -0800
+++ highscore.c 2004-02-28 10:27:07.000000000 -0800
@@ -54,6 +54,9 @@
#include <unistd.h>
#include <time.h>
#include <file.h>
+#ifdef __NetBSD__
+ #include <sys/file.h>
+#endif
#include <sys/param.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -1022,9 +1025,10 @@ int ReadHighScoreTable(type)
if (type == GLOBAL)
{
/* Use the environment variable if it exists */
- if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
- strcpy(filename, str);
- else
+ if ((str = getenv("XBOING_SCORE_FILE")) != NULL) {
+ strncpy(filename, str, sizeof(filename)-1);
+ filename[sizeof(filename)-1] = '\0';
+ } else
strcpy(filename, HIGH_SCORE_FILE);
}
else
@@ -1094,9 +1098,10 @@ int WriteHighScoreTable(type)
if (type == GLOBAL)
{
/* Use the environment variable if it exists */
- if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
- strcpy(filename, str);
- else
+ if ((str = getenv("XBOING_SCORE_FILE")) != NULL) {
+ strncpy(filename, str, sizeof(filename)-1);
+ filename[sizeof(filename)-1] = '\0';
+ } else
strcpy(filename, HIGH_SCORE_FILE);
}
else
@@ -1217,9 +1222,10 @@ static int LockUnlock(cmd)
/* Use the environment variable if it exists */
- if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
- strcpy(filename, str);
- else
+ if ((str = getenv("XBOING_SCORE_FILE")) != NULL) {
+ strncpy(filename, str, sizeof(filename)-1);
+ filename[sizeof(filename)-1] = '\0';
+ } else
strcpy(filename, HIGH_SCORE_FILE);
/* Open the highscore file for both read & write */