[BACK]Return to patch-ad CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / games / xpipeman / patches

File: [cvs.NetBSD.org] / pkgsrc / games / xpipeman / patches / patch-ad (download)

Revision 1.4, Sat Jan 30 18:42:47 2021 UTC (8 months, 3 weeks ago) by rillig
Branch: MAIN
CVS Tags: pkgsrc-2021Q3-base, pkgsrc-2021Q3, pkgsrc-2021Q2-base, pkgsrc-2021Q2, pkgsrc-2021Q1-base, pkgsrc-2021Q1, HEAD
Changes since 1.3: +10 -1 lines

games/xpipeman: fix buffer overflow when starting the game

$NetBSD: patch-ad,v 1.4 2021/01/30 18:42:47 rillig Exp $

--- main.c.orig	1991-09-13 20:32:10.000000000 +0000
+++ main.c
@@ -52,6 +52,9 @@
 #include <X11/Xaw/Box.h>
 #endif
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 #include "xpipeman.h"
 
@@ -138,9 +141,7 @@ static XtActionsRec actions[] = {
   {"do_nothing",(XtActionProc)do_nothing_action},
 };
 
-Pixel fg, bg;
-
-XtTranslations translations;
+AppData app_data;
 
 static XrmOptionDescRec options[] = {
 	{"-scorefile","scorefile",XrmoptionSepArg, NULL },
@@ -148,19 +149,20 @@ static XrmOptionDescRec options[] = {
 
 static XtResource application_resources[] = {
   {"foreground", "Foreground", XtRPixel, sizeof(Pixel),
-                (Cardinal)&fg, XtRString, (caddr_t) "Black"},
+                XtOffsetOf(AppData,fg), XtRString, (caddr_t) "Black"},
   {"background", "Background", XtRPixel, sizeof(Pixel),
-                (Cardinal)&bg, XtRString, (caddr_t) "White"},
+                XtOffsetOf(AppData,bg), XtRString, (caddr_t) "White"},
   {"translations","Translations", XtRTranslationTable, sizeof(XtTranslations),
-                (Cardinal)&translations, XtRString, (caddr_t)translations_str},
+                XtOffsetOf(AppData,translations), XtRString,(caddr_t)translations_str},
   {"scorefile","Scorefile", XtRString, sizeof(String),
-                (Cardinal)&score_filename, XtRString, (caddr_t)SCORE_FILE},
+                XtOffsetOf(AppData,score_filename), XtRString,(caddr_t)SCORE_FILE},
 };
 
 /*----------------------------------------------------------------------*/
 
+int
 main(argc, argv)
-  unsigned int argc;
+  int argc;
   char **argv;
 {
   Arg args[1];
@@ -177,7 +179,7 @@ main(argc, argv)
 
   XtAddActions(actions,XtNumber(actions));
 
-  XtGetApplicationResources(top_shell, 0, application_resources, 
+  XtGetApplicationResources(top_shell, &app_data, application_resources, 
 			XtNumber(application_resources), NULL, 0 );
 
   top_widget = XtCreateManagedWidget(
@@ -193,7 +195,7 @@ main(argc, argv)
                                     arglistplayfield,
                                     XtNumber(arglistplayfield));
 
-  XtAugmentTranslations(playfield_widget,translations);
+  XtAugmentTranslations(playfield_widget,app_data.translations);
 
   quit_command = XtCreateManagedWidget(
                                     "quit_button",
@@ -263,12 +265,12 @@ main(argc, argv)
 
   display   = XtDisplay(playfield_widget);
   playfield = XtWindow(playfield_widget);
-  gcv.foreground = fg;
-  gcv.background = bg;
+  gcv.foreground = app_data.fg;
+  gcv.background = app_data.bg;
   gcv.function = GXcopy;
   gc = XCreateGC(display, playfield, 
  		GCForeground | GCBackground | GCFunction, &gcv);
-  gcv.foreground = bg;
+  gcv.foreground = app_data.bg;
   cleargc = XCreateGC(display, playfield,
  		 GCForeground | GCBackground | GCFunction, &gcv);
 
@@ -318,7 +320,7 @@ void
 update_remain(score)
   int score;
 {
-  char text[13];
+  char text[16];
   (void)sprintf(text,"Remaining: %4d",score);
   XtSetArg(arglistremain_command[0],XtNlabel,text);
   XtSetValues(remain_command,arglistremain_command,1);