Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9644) remove global long_buffer
Home

[Freeciv-Dev] (PR#9644) remove global long_buffer

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9644) remove global long_buffer
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 8 Aug 2004 23:50:13 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9644 >

There is a global

   char long_buffer[64000];

in the client.  The first problem is that this is 64k of unused memory 
for clients that don't use this buffer.  The second problem is that it's 
unsafe to actually use this buffer, since the whole point of it is that 
it is "safely" longer than any text will be but this isn't a good 
assumption because the text could come from a malicious source.

(What kind of malicious source that would be I don't know.  A ruleset 
that, when used, runs a virus on your computer?  Seems far-fetched.  But 
the whole thing is just ugly and should be fixed.)

This patch removes it from global usage.  It doesn't actually fix any 
security problems since the 64k buffer is still used in all the same 
places, it just isn't global any more.  However it does avoid the 64k 
overhead for gui-ftwl (as if anyone cares).

Of course the users of the long_buffer should also be fixed.

jason

? diff
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.70
diff -u -r1.70 helpdata.c
--- client/helpdata.c   8 May 2004 00:00:21 -0000       1.70
+++ client/helpdata.c   9 Aug 2004 06:46:14 -0000
@@ -62,8 +62,6 @@
    latter can be 0 even after call, eg if couldn't find helpdata.txt.
 */
 
-char long_buffer[64000];
-
 /****************************************************************
   Make sure help_nodes is initialised.
   Should call this just about everywhere which uses help_nodes,
@@ -183,6 +181,7 @@
   int i, isec;
   char **sec, **paras;
   int nsec, npara;
+  char long_buffer[64000];
 
   check_help_nodes_init();
 
Index: client/helpdata.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.h,v
retrieving revision 1.7
diff -u -r1.7 helpdata.h
--- client/helpdata.h   28 Sep 2002 01:36:20 -0000      1.7
+++ client/helpdata.h   9 Aug 2004 06:46:14 -0000
@@ -46,6 +46,4 @@
         while((pitem=help_iter_next())) {   
 #define help_items_iterate_end }}
 
-extern char long_buffer[64000];
-
 #endif  /* FC__HELPDATA_H */
Index: client/gui-gtk/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/helpdlg.c,v
retrieving revision 1.65
diff -u -r1.65 helpdlg.c
--- client/gui-gtk/helpdlg.c    25 Feb 2004 20:09:50 -0000      1.65
+++ client/gui-gtk/helpdlg.c    9 Aug 2004 06:46:14 -0000
@@ -106,6 +106,9 @@
     { N_("Mine Rslt/Time:"),   NULL, NULL, N_("Trans. Rslt/Time:"),    NULL }
 };
 
+/* HACK: we use a static string for convenience. */
+static char long_buffer[64000];
+
 
 static void create_help_dialog(void);
 static void help_update_dialog(const struct help_item *pitem);
Index: client/gui-gtk-2.0/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/helpdlg.c,v
retrieving revision 1.32
diff -u -r1.32 helpdlg.c
--- client/gui-gtk-2.0/helpdlg.c        17 May 2004 05:34:53 -0000      1.32
+++ client/gui-gtk-2.0/helpdlg.c        9 Aug 2004 06:46:14 -0000
@@ -107,6 +107,9 @@
     { N_("Mine Rslt/Time:"),   NULL, NULL, N_("Trans. Rslt/Time:"),    NULL }
 };
 
+/* HACK: we use a static string for convenience. */
+static char long_buffer[64000];
+
 
 static void create_help_dialog(void);
 static void help_update_dialog(const struct help_item *pitem);
Index: client/gui-sdl/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/helpdlg.c,v
retrieving revision 1.5
diff -u -r1.5 helpdlg.c
--- client/gui-sdl/helpdlg.c    25 Feb 2004 20:09:51 -0000      1.5
+++ client/gui-sdl/helpdlg.c    9 Aug 2004 06:46:15 -0000
@@ -83,6 +83,9 @@
   HELP_LAST
 } current_help_dlg = HELP_LAST;
 
+/* HACK: we use a static string for convenience. */
+static char long_buffer[64000];
+
 static int change_tech_callback(struct GUI *pWidget);
   
 /**************************************************************************
Index: client/gui-win32/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/helpdlg.c,v
retrieving revision 1.18
diff -u -r1.18 helpdlg.c
--- client/gui-win32/helpdlg.c  25 Feb 2004 20:09:51 -0000      1.18
+++ client/gui-win32/helpdlg.c  9 Aug 2004 06:46:15 -0000
@@ -51,7 +51,9 @@
 #define ID_HELP_IMPROVEMENT_LINK 112
 #define ID_HELP_WONDER_LINK 113
 
-extern char long_buffer[64000];
+/* HACK: we use a static string for convenience. */
+static char long_buffer[64000];
+
 extern HINSTANCE freecivhinst;
 extern HWND root_window;
 static HWND helpdlg_win;
Index: client/gui-xaw/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/helpdlg.c,v
retrieving revision 1.49
diff -u -r1.49 helpdlg.c
--- client/gui-xaw/helpdlg.c    25 Feb 2004 20:09:51 -0000      1.49
+++ client/gui-xaw/helpdlg.c    9 Aug 2004 06:46:15 -0000
@@ -91,6 +91,9 @@
 static Widget help_terrain_mining_result_time, 
help_terrain_mining_result_time_data;
 static Widget help_terrain_transform_result_time, 
help_terrain_transform_result_time_data;
 
+/* HACK: we use a static string for convenience. */
+static char long_buffer[64000];
+
 static void create_help_page(enum help_page_type type);
 
 static void help_close_command_callback(Widget w, XtPointer client_data, 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9644) remove global long_buffer, Jason Short <=