]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
replace control characters (such as newline) with _ in savegame comments, this fixes...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 16 Jun 2005 22:43:37 +0000 (22:43 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 16 Jun 2005 22:43:37 +0000 (22:43 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5443 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c

index fae72a98624ba40d157eacf316ba7099dcd6ad49..59eaee050b52538e971683b43fb1c0394e16a32f 100644 (file)
@@ -435,12 +435,14 @@ void Host_SavegameComment (char *text)
 
        for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
                text[i] = ' ';
-       memcpy (text, cl.levelname, strlen(cl.levelname));
+       // LordHavoc: added min() to prevent overflow
+       memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
        sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
        memcpy (text+22, kills, strlen(kills));
-// convert space to _ to make stdio happy
+       // convert space to _ to make stdio happy
+       // LordHavoc: convert control characters to _ as well
        for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
-               if (text[i] == ' ')
+               if (text[i] <= ' ')
                        text[i] = '_';
        text[SAVEGAME_COMMENT_LENGTH] = '\0';
 }