summaryrefslogtreecommitdiffstats
path: root/games/sxsame/files/patch-loadbmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'games/sxsame/files/patch-loadbmp.c')
-rw-r--r--games/sxsame/files/patch-loadbmp.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/games/sxsame/files/patch-loadbmp.c b/games/sxsame/files/patch-loadbmp.c
new file mode 100644
index 0000000..9d193e2
--- /dev/null
+++ b/games/sxsame/files/patch-loadbmp.c
@@ -0,0 +1,39 @@
+--- loadbmp.c.orig Sun May 5 04:09:25 1996
++++ loadbmp.c Tue Jul 11 21:30:24 2000
+@@ -5,6 +5,9 @@
+ * Copyleft (c) 1994-1996 Software Research Academy *
+ ************************************************************************/
+ #include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <sys/param.h>
+ #include <X11/Xlib.h>
+ #include "sxsame.h"
+
+@@ -37,17 +40,24 @@
+ int c, c1,c2;
+ int width, height, planes, ncol;
+ int *col;
+- char fname[256];
++ char fname[MAXPATHLEN];
+
+ Pixmap w;
+ GC gc;
+ int i, j, k;
+
++ if (MAXPATHLEN <= strlen(bmpname) ) {
++ fprintf(stderr,"Error: BMP file name too long.\n");
++ return -1;
++ }
+ strcpy(fname,bmpname);
+ fp = fopen(fname,"rb");
+ if(fp == NULL)
+ {
+- sprintf(fname, "%s/%s", SAME_DIR, bmpname);
++ if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN, "%s/%s", SAME_DIR, bmpname)) {
++ fprintf(stderr,"Error: BMP file name too long.\n");
++ return -1;
++ }
+ fp = fopen(fname, "r");
+ if(fp == NULL)
+ {
OpenPOWER on IntegriCloud