[AD] Re: CVS: allegro/src/dos gripjoy.c,1.9,1.10 sndscape.c,1.8,1.9

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


It's great that there's some activity on the CVS list...

Index: gripjoy.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/dos/gripjoy.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- gripjoy.c	6 Nov 2001 17:16:39 -0000	1.9
+++ gripjoy.c	2 Jul 2004 16:25:41 -0000	1.10
@@ -288,7 +288,7 @@
	    stick_class[i][stick] = GRIP_CLASS_AXIS;

	    /* name stick... :( */
-	    strcpy(tmpstr, "Stick");
+	    _al_sane_strncpy(tmpstr, "Stick", 1287);
	    if (joy[i].num_sticks > 1) {
	       tmpstr[strlen(tmpstr)+2] = '\0';
	       tmpstr[strlen(tmpstr)+1] = '1'+stick;
[snip more of the same]

... but there's no need to get silly with this kind of thing. The strcpy() call was perfectly safe. Now it's unreadable.

-static int get_ini_config_entry(char *entry, char *dest, FILE *fp)
+static int get_ini_config_entry(char *entry, char *dest, unsigned int dest_size, FILE *fp)
{
   char str[83];
   char tokstr[33];
   char *p;

   /* make a local copy of the entry, upper-case it */
-   strcpy(tokstr, entry);
+   _al_sane_strncpy(tokstr, entry, 33);

Please use sizeof where appropriate.

Peter





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