* Prevent environment variables from overflowing buffers.
Adapted from Debian via Robert Nagy <thuglife@bsd.hu>. * Fix high score file handling.
This commit is contained in:
parent
07f0e962cc
commit
11467f34ea
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.17 2003/06/18 21:43:40 pvalchev Exp $
|
||||
# $OpenBSD: Makefile,v 1.18 2004/03/06 02:41:00 naddy Exp $
|
||||
|
||||
COMMENT= "blockout style game for X11"
|
||||
|
||||
@ -14,8 +14,9 @@ PERMIT_DISTFILES_FTP= Yes
|
||||
MASTER_SITES= ${MASTER_SITE_XCONTRIB:=games/}
|
||||
|
||||
CONFIGURE_STYLE=imake
|
||||
WRKDIST= ${WRKDIR}/xboing
|
||||
WRKDIST= ${WRKDIR}/xboing
|
||||
|
||||
USE_X11= Yes
|
||||
NO_REGRESS= Yes
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
@ -1,7 +1,7 @@
|
||||
$OpenBSD: patch-Imakefile,v 1.3 2004/03/05 22:56:42 naddy Exp $
|
||||
$OpenBSD: patch-Imakefile,v 1.4 2004/03/06 02:41:00 naddy Exp $
|
||||
--- Imakefile.orig 1996-11-22 02:28:46.000000000 +0100
|
||||
+++ Imakefile 2004-03-05 23:30:39.000000000 +0100
|
||||
@@ -24,23 +24,22 @@ XCOMM ==================================
|
||||
+++ Imakefile 2004-03-06 02:34:53.000000000 +0100
|
||||
@@ -24,23 +24,23 @@ XCOMM ==================================
|
||||
XCOMM This is the directory where the highscore, level & sound data will be
|
||||
XCOMM placed. Default will be the current directory.
|
||||
|
||||
@ -19,9 +19,11 @@ $OpenBSD: patch-Imakefile,v 1.3 2004/03/05 22:56:42 naddy Exp $
|
||||
LEVEL_INSTALL_DIR = $(XBOING_DIR)/levels
|
||||
SOUNDS_DIR = $(XBOING_DIR)/sounds
|
||||
BACKUP_DIR = $(XBOING_DIR)/../backups
|
||||
HIGH_SCORE_FILE = $(XBOING_DIR)/.xboing.scr
|
||||
- HIGH_SCORE_FILE = $(XBOING_DIR)/.xboing.scr
|
||||
- AUDIO_AVAILABLE = False
|
||||
- AUDIO_SRC = audio/NOaudio.c
|
||||
+ HIGH_SCORE_DIR = /var/games
|
||||
+ HIGH_SCORE_FILE = $(HIGH_SCORE_DIR)/xboing.score
|
||||
+ AUDIO_AVAILABLE = True
|
||||
+ AUDIO_SRC = audio/LINUXaudio.c
|
||||
AUDIO_INCLUDE =
|
||||
@ -31,7 +33,7 @@ $OpenBSD: patch-Imakefile,v 1.3 2004/03/05 22:56:42 naddy Exp $
|
||||
|
||||
XCOMM Uncomment this if you want to use ANY of the AUDIO sound systems
|
||||
#define COMPILE_IN_AUDIO
|
||||
@@ -81,7 +80,7 @@ XCOMM Below are the special defines for
|
||||
@@ -81,7 +81,7 @@ XCOMM Below are the special defines for
|
||||
AUDIO_LIB = -laudio
|
||||
#endif /* SGIArchitecture */
|
||||
|
||||
@ -40,7 +42,7 @@ $OpenBSD: patch-Imakefile,v 1.3 2004/03/05 22:56:42 naddy Exp $
|
||||
AUDIO_AVAILABLE = True
|
||||
AUDIO_SRC = audio/SUNaudio.c
|
||||
|
||||
@@ -132,8 +131,8 @@ XCOMM hasn't a usleep() function.
|
||||
@@ -132,8 +132,8 @@ XCOMM hasn't a usleep() function.
|
||||
-DLEVEL_INSTALL_DIR=\"$(LEVEL_INSTALL_DIR)\" \
|
||||
-DAUDIO_AVAILABLE=\"$(AUDIO_AVAILABLE)\" \
|
||||
-DSOUNDS_DIR=\"$(SOUNDS_DIR)\" \
|
||||
@ -51,3 +53,13 @@ $OpenBSD: patch-Imakefile,v 1.3 2004/03/05 22:56:42 naddy Exp $
|
||||
XCOMM -DNEED_USLEEP=\"True\" \
|
||||
XCOMM -DNO_LOCKING=\"True\"
|
||||
|
||||
@@ -203,9 +203,6 @@ install:: $(PROGRAMS)
|
||||
done; \
|
||||
fi
|
||||
@:
|
||||
- @echo "Creating a highscore file " $(HIGH_SCORE_FILE)
|
||||
- @touch $(HIGH_SCORE_FILE);
|
||||
- @chmod a+rw $(HIGH_SCORE_FILE);
|
||||
|
||||
XCOMM I use this for my daily backup of my code.
|
||||
|
||||
|
12
games/xboing/patches/patch-demo_c
Normal file
12
games/xboing/patches/patch-demo_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-demo_c,v 1.1 2004/03/06 02:41:00 naddy Exp $
|
||||
--- demo.c.orig 2004-03-06 01:50:10.000000000 +0100
|
||||
+++ demo.c 2004-03-06 01:51:28.000000000 +0100
|
||||
@@ -154,7 +154,7 @@ static void DoBlocks(display, window)
|
||||
|
||||
/* Construct the demo level filename */
|
||||
if ((str = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
- sprintf(levelPath, "%s/demo.data", str);
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/demo.data", str);
|
||||
else
|
||||
sprintf(levelPath, "%s/demo.data", LEVEL_INSTALL_DIR);
|
||||
|
@ -1,6 +1,15 @@
|
||||
$OpenBSD: patch-editor_c,v 1.1 2004/03/05 22:56:42 naddy Exp $
|
||||
$OpenBSD: patch-editor_c,v 1.2 2004/03/06 02:41:00 naddy Exp $
|
||||
--- editor.c.orig 1996-11-22 02:28:46.000000000 +0100
|
||||
+++ editor.c 2004-03-05 23:30:39.000000000 +0100
|
||||
+++ editor.c 2004-03-06 01:55:49.000000000 +0100
|
||||
@@ -213,7 +213,7 @@ static void DoLoadLevel(display, window)
|
||||
|
||||
/* Construct the Edit level filename */
|
||||
if ((str = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
- sprintf(levelPath, "%s/editor.data", str);
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/editor.data", str);
|
||||
else
|
||||
sprintf(levelPath, "%s/editor.data", LEVEL_INSTALL_DIR);
|
||||
|
||||
@@ -652,9 +652,15 @@ static void SetupPlayTest(display)
|
||||
Display *display;
|
||||
#endif
|
||||
@ -18,3 +27,29 @@ $OpenBSD: patch-editor_c,v 1.1 2004/03/05 22:56:42 naddy Exp $
|
||||
if (SaveLevelDataFile(display, tempName) == False)
|
||||
ShutDown(display, 1, "Sorry, cannot save test play level.");
|
||||
|
||||
@@ -957,9 +963,9 @@ static void LoadALevel(display)
|
||||
num = atoi(str);
|
||||
if ((num > 0) && (num <= MAX_NUM_LEVELS))
|
||||
{
|
||||
- /* Construct the Edit level filename */
|
||||
- if ((str2 = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
- sprintf(levelPath, "%s/level%02ld.data", str2, (u_long) num);
|
||||
+ /* Construct the Edit level filename */
|
||||
+ if ((str2 = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/level%02ld.data", str2, (u_long) num);
|
||||
else
|
||||
sprintf(levelPath, "%s/level%02ld.data",
|
||||
LEVEL_INSTALL_DIR, (u_long) num);
|
||||
@@ -1017,9 +1023,9 @@ static void SaveALevel(display)
|
||||
num = atoi(str);
|
||||
if ((num > 0) && (num <= MAX_NUM_LEVELS))
|
||||
{
|
||||
- /* Construct the Edit level filename */
|
||||
- if ((str2 = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
- sprintf(levelPath, "%s/level%02ld.data", str2, (u_long) num);
|
||||
+ /* Construct the Edit level filename */
|
||||
+ if ((str2 = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/level%02ld.data", str2, (u_long) num);
|
||||
else
|
||||
sprintf(levelPath, "%s/level%02ld.data",
|
||||
LEVEL_INSTALL_DIR, (u_long) num);
|
||||
|
48
games/xboing/patches/patch-file_c
Normal file
48
games/xboing/patches/patch-file_c
Normal file
@ -0,0 +1,48 @@
|
||||
$OpenBSD: patch-file_c,v 1.1 2004/03/06 02:41:00 naddy Exp $
|
||||
--- file.c.orig 2004-03-06 01:56:25.000000000 +0100
|
||||
+++ file.c 2004-03-06 01:58:32.000000000 +0100
|
||||
@@ -139,7 +139,7 @@ void SetupStage(display, window)
|
||||
|
||||
/* Construct the level filename */
|
||||
if ((str = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
- sprintf(levelPath, "%s/level%02ld.data", str, newLevel);
|
||||
+ sprintf(levelPath, sizeof(levelPath), "%s/level%02ld.data", str, newLevel);
|
||||
else
|
||||
sprintf(levelPath, "%s/level%02ld.data", LEVEL_INSTALL_DIR, newLevel);
|
||||
|
||||
@@ -177,7 +177,7 @@ int LoadSavedGame(display, window)
|
||||
static int bgrnd = 1;
|
||||
|
||||
/* Save the file in home directory - construct path */
|
||||
- sprintf(levelPath, "%s/.xboing-saveinfo", GetHomeDir());
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/.xboing-saveinfo", GetHomeDir());
|
||||
|
||||
/* Open the save file info for reading */
|
||||
if ((saveFile = fopen(levelPath, "r+")) == NULL)
|
||||
@@ -239,7 +239,7 @@ int LoadSavedGame(display, window)
|
||||
DisplayLevelInfo(display, levelWindow, level);
|
||||
|
||||
/* Load the saved file in home directory - construct path */
|
||||
- sprintf(levelPath, "%s/.xboing-savelevel", GetHomeDir());
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/.xboing-savelevel", GetHomeDir());
|
||||
|
||||
/* Read in the saved level data */
|
||||
if (ReadNextLevel(display, window, levelPath, True) == False)
|
||||
@@ -283,7 +283,7 @@ int SaveCurrentGame(display, window)
|
||||
saveGame.numBullets = GetNumberBullets();
|
||||
|
||||
/* Save the file in home directory - construct path */
|
||||
- sprintf(levelPath, "%s/.xboing-saveinfo", GetHomeDir());
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/.xboing-saveinfo", GetHomeDir());
|
||||
|
||||
/* Open the save file info for writing */
|
||||
if ((saveFile = fopen(levelPath, "w+")) == NULL)
|
||||
@@ -309,7 +309,7 @@ int SaveCurrentGame(display, window)
|
||||
WarningMessage("Cannot close save game info file.");
|
||||
|
||||
/* Save the file in home directory - construct path */
|
||||
- sprintf(levelPath, "%s/.xboing-savelevel", GetHomeDir());
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/.xboing-savelevel", GetHomeDir());
|
||||
|
||||
if (SaveLevelDataFile(display, levelPath) == True)
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-highscore.c,v 1.2 2004/03/05 22:56:42 naddy Exp $
|
||||
$OpenBSD: patch-highscore.c,v 1.3 2004/03/06 02:41:00 naddy Exp $
|
||||
--- highscore.c.orig 1996-11-22 02:28:46.000000000 +0100
|
||||
+++ highscore.c 2004-03-05 23:30:39.000000000 +0100
|
||||
+++ highscore.c 2004-03-06 02:01:05.000000000 +0100
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <time.h>
|
||||
#include <file.h>
|
||||
@ -58,6 +58,15 @@ $OpenBSD: patch-highscore.c,v 1.2 2004/03/05 22:56:42 naddy Exp $
|
||||
|
||||
/* Not even a highscore - loser! */
|
||||
return False;
|
||||
@@ -1023,7 +1025,7 @@ int ReadHighScoreTable(type)
|
||||
{
|
||||
/* Use the environment variable if it exists */
|
||||
if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
|
||||
- strcpy(filename, str);
|
||||
+ strlcpy(filename, str, sizeof(filename));
|
||||
else
|
||||
strcpy(filename, HIGH_SCORE_FILE);
|
||||
}
|
||||
@@ -1185,10 +1187,10 @@ void ResetHighScore(type)
|
||||
}
|
||||
|
||||
@ -71,7 +80,15 @@ $OpenBSD: patch-highscore.c,v 1.2 2004/03/05 22:56:42 naddy Exp $
|
||||
#endif
|
||||
{
|
||||
static int inter = -1;
|
||||
@@ -1225,6 +1227,9 @@ static int LockUnlock(cmd)
|
||||
@@ -1218,13 +1220,16 @@ static int LockUnlock(cmd)
|
||||
|
||||
/* Use the environment variable if it exists */
|
||||
if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
|
||||
- strcpy(filename, str);
|
||||
+ strlcpy(filename, str, sizeof(filename));
|
||||
else
|
||||
strcpy(filename, HIGH_SCORE_FILE);
|
||||
|
||||
/* Open the highscore file for both read & write */
|
||||
if (cmd == LOCK_FILE)
|
||||
inter = open(filename, O_CREAT | O_RDWR, 0666);
|
||||
|
12
games/xboing/patches/patch-init_c
Normal file
12
games/xboing/patches/patch-init_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-init_c,v 1.1 2004/03/06 02:41:00 naddy Exp $
|
||||
--- init.c.orig 2004-03-06 00:49:08.000000000 +0100
|
||||
+++ init.c 2004-03-06 02:02:14.000000000 +0100
|
||||
@@ -438,7 +438,7 @@ static void HandleDisplayErrors(displayN
|
||||
WarningMessage("Your X Window system display variable is not set.");
|
||||
else
|
||||
{
|
||||
- sprintf(string, "Cannot connect to display called <%s>.", displayName);
|
||||
+ snprintf(string, sizeof(string), "Cannot connect to display called <%s>.", displayName);
|
||||
WarningMessage(string);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-misc_c,v 1.1 2004/03/05 22:56:42 naddy Exp $
|
||||
$OpenBSD: patch-misc_c,v 1.2 2004/03/06 02:41:00 naddy Exp $
|
||||
--- misc.c.orig 1996-11-22 02:28:46.000000000 +0100
|
||||
+++ misc.c 2004-03-05 23:30:39.000000000 +0100
|
||||
+++ misc.c 2004-03-06 02:03:24.000000000 +0100
|
||||
@@ -89,8 +89,8 @@ void usleep(usec)
|
||||
#ifdef SYSV
|
||||
#ifdef __clipper__
|
||||
@ -182,3 +182,21 @@ $OpenBSD: patch-misc_c,v 1.1 2004/03/05 22:56:42 naddy Exp $
|
||||
}
|
||||
|
||||
#if NeedFunctionPrototypes
|
||||
@@ -427,7 +547,7 @@ char *GetHomeDir()
|
||||
*/
|
||||
|
||||
if ((ptr = getenv("HOME")) != NULL)
|
||||
- (void) strcpy(dest, ptr);
|
||||
+ (void) strlcpy(dest, ptr, sizeof(dest));
|
||||
else
|
||||
{
|
||||
/* HOME variable is not present so get USER var */
|
||||
@@ -441,7 +561,7 @@ char *GetHomeDir()
|
||||
}
|
||||
|
||||
if (pw)
|
||||
- (void) strcpy(dest, pw->pw_dir);
|
||||
+ (void) strlcpy(dest, pw->pw_dir, sizeof(dest));
|
||||
else
|
||||
*dest = '\0';
|
||||
}
|
||||
|
12
games/xboing/patches/patch-preview_c
Normal file
12
games/xboing/patches/patch-preview_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-preview_c,v 1.1 2004/03/06 02:41:00 naddy Exp $
|
||||
--- preview.c.orig 2004-03-06 02:03:41.000000000 +0100
|
||||
+++ preview.c 2004-03-06 02:04:07.000000000 +0100
|
||||
@@ -139,7 +139,7 @@ static void DoLoadLevel(display, window)
|
||||
|
||||
/* Construct the Preview level filename */
|
||||
if ((str = getenv("XBOING_LEVELS_DIR")) != NULL)
|
||||
- sprintf(levelPath, "%s/level%02d.data", str, lnum);
|
||||
+ snprintf(levelPath, sizeof(levelPath), "%s/level%02d.data", str, lnum);
|
||||
else
|
||||
sprintf(levelPath, "%s/level%02d.data", LEVEL_INSTALL_DIR, lnum);
|
||||
|
45
games/xboing/pkg/DEINSTALL
Normal file
45
games/xboing/pkg/DEINSTALL
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# $OpenBSD: DEINSTALL,v 1.1 2004/03/06 02:41:00 naddy Exp $
|
||||
|
||||
set -e
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
PREFIX=${PKG_PREFIX:-/usr/local}
|
||||
SCORE_FILE=/var/games/xboing.score
|
||||
|
||||
do_notice()
|
||||
{
|
||||
echo
|
||||
echo "+---------------"
|
||||
echo "| To completely deinstall the $1 package you need to perform"
|
||||
echo "| this step as root:"
|
||||
echo "|"
|
||||
echo "| rm -f $SCORE_FILE"
|
||||
echo "|"
|
||||
echo "| Do not do this if you plan on re-installing $1"
|
||||
echo "| at some future time."
|
||||
echo "+---------------"
|
||||
echo
|
||||
}
|
||||
|
||||
# Verify proper execution
|
||||
#
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: $0 distname DEINSTALL" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify/process the command
|
||||
#
|
||||
case $2 in
|
||||
DEINSTALL)
|
||||
if [ "$PKG_DELETE_EXTRA" != Yes -a -f $SCORE_FILE ]; then
|
||||
do_notice "$1"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 distname DEINSTALL" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -2,5 +2,3 @@ XBoing is a blockout type game where you have a paddle which you use
|
||||
to bounce a ball around the game area blowing up blocks with the ball.
|
||||
You win by obtaining points for each block destroyed and each level
|
||||
completed. The person with the highest score wins.
|
||||
|
||||
This is version 2.4.
|
||||
|
59
games/xboing/pkg/INSTALL
Normal file
59
games/xboing/pkg/INSTALL
Normal file
@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
# $OpenBSD: INSTALL,v 1.1 2004/03/06 02:41:00 naddy Exp $
|
||||
|
||||
# exit on errors, use a sane path and install prefix
|
||||
#
|
||||
set -e
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
PREFIX=${PKG_PREFIX:-/usr/local}
|
||||
SCORE_FILE=/var/games/xboing.score
|
||||
|
||||
# Function: tell the user what they need to do to use the port just installed
|
||||
#
|
||||
do_notice()
|
||||
{
|
||||
echo
|
||||
echo "+---------------"
|
||||
echo "| The existing $1 score file,"
|
||||
echo "| $SCORE_FILE,"
|
||||
echo "| has NOT been changed."
|
||||
echo "+---------------"
|
||||
echo
|
||||
}
|
||||
|
||||
# Function: install a blank file to be used as the gtkballs score file
|
||||
#
|
||||
do_install()
|
||||
{
|
||||
touch $SCORE_FILE
|
||||
chown root:games $SCORE_FILE
|
||||
chmod 664 $SCORE_FILE
|
||||
}
|
||||
|
||||
# verify proper execution
|
||||
#
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify/process the command
|
||||
#
|
||||
case $2 in
|
||||
PRE-INSTALL)
|
||||
: nothing to pre-install for this port
|
||||
;;
|
||||
POST-INSTALL)
|
||||
if [ -f $SCORE_FILE ]; then
|
||||
do_notice $1
|
||||
else
|
||||
do_install $1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -1,7 +1,10 @@
|
||||
@comment $OpenBSD: PLIST,v 1.4 2002/04/07 01:54:49 naddy Exp $
|
||||
@comment $OpenBSD: PLIST,v 1.5 2004/03/06 02:41:00 naddy Exp $
|
||||
@mode g+s
|
||||
@group games
|
||||
bin/xboing
|
||||
@mode
|
||||
@group
|
||||
man/cat1/xboing.0
|
||||
share/xboing/.xboing.scr
|
||||
share/xboing/levels/demo.data
|
||||
share/xboing/levels/editor.data
|
||||
share/xboing/levels/level01.data
|
||||
@ -135,3 +138,5 @@ share/xboing/sounds/youagod.au
|
||||
@dirrm share/xboing/sounds
|
||||
@dirrm share/xboing/levels
|
||||
@dirrm share/xboing
|
||||
@cwd /var/games
|
||||
@extra xboing.score
|
||||
|
Loading…
Reference in New Issue
Block a user