[AD] d_edit_proc bug in grabber

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I made excustom display in a bigger font, and to my surprise, it
instantly crashed on me :P The problem was the d1 field in the
d_edit_proc, which was too short for the unicode characters I entered..

The attached patch fixes the same crash in grabber, when entering long
unicode strings into its text boxes. I remember, the behaviour of
d_edit_box regarding character/byte count already was discussed some
time ago, but I don't know anymore what was the conclusion - and
apparently, grabber was left in this unsafe state.

Anyway, with the current behaviour, I think there should be a note in
the d_edit_proc docs how many space the string in dp must provide so it
won't overflow.

-- 
Elias Pschernig <elias@xxxxxxxxxx>
Index: grabber.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/grabber.c,v
retrieving revision 1.53
diff -u -r1.53 grabber.c
--- grabber.c	12 May 2003 08:02:42 -0000	1.53
+++ grabber.c	30 May 2003 09:23:22 -0000
@@ -30,6 +30,7 @@
 
 
 #define FILENAME_LENGTH  1024
+#define MAX_BYTES_PER_CHAR 6
 
 
 typedef struct DATAITEM
@@ -47,12 +48,12 @@
 static int data_count = 0;
 static int data_malloced = 0;
 
-static char data_file[256] = "";
-static char header_file[256] = "";
-static char prefix_string[256] = "";
-static char password[256];
-static char xgrid_string[16];
-static char ygrid_string[16];
+static char data_file[256 * MAX_BYTES_PER_CHAR] = "";
+static char header_file[256 * MAX_BYTES_PER_CHAR] = "";
+static char prefix_string[256 * MAX_BYTES_PER_CHAR] = "";
+static char password[256 * MAX_BYTES_PER_CHAR];
+static char xgrid_string[5 * MAX_BYTES_PER_CHAR];
+static char ygrid_string[5 * MAX_BYTES_PER_CHAR];
 
 static int current_view_object = -1;
 static int current_property_object = -1;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/