[CODE] How to fix playerfile

From: Andrey Fidrya (andrey@alex-ua.com)
Date: 06/24/99


To fix broken playerfile (buffer overflow bug):

Edit db.c, char_to_store():
-  if (ch->player.description)
-    strcpy(st->description, ch->player.description);
-  else
-    *st->description = '\0';
+ if (ch->player.description) {
+   if (strlen(ch->player.description) >= EXDSCR_LENGTH) {
+     log("SYSERR: char_to_store: %s's description length: %d, max: %d! "
+        "Truncated.", GET_PC_NAME(ch), strlen(ch->player.description),
+        EXDSCR_LENGTH);
+     ch->player.description[EXDSCR_LENGTH - 3] = '\0';
+     strcat(ch->player.description, "\r\n");
+   }
+   strcpy(st->description, ch->player.description);
+ } else
+   *st->description = '\0';


Without this fix, every time you edit someone's titles, they will be nulled
yet and yet again until you reset char's description. This piece of code
truncates broken descriptions automatically.

Zmey // 3MoonsWorld (rmud.net.ru:4000)


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST