[BUG] Stock bug in player descriptions Myrseth at "Apr 15, 99 03:51:10 pm"

From: Martijn Schoemaker (mschoe@osp.nl)
Date: 04/15/99


Hi all,

Just found a stock bug in the player description code. It causes
players titles to 'disapear' or not to get saved properly.

The origination of the problem lies in structs.h :

struct char_file_u {
   /* char_player_data */
   char name[MAX_NAME_LENGTH+1];
   char description[EXDSCR_LENGTH]; << As you can see, no '+1'
   char title[MAX_TITLE_LENGTH+1];

Now the problem is that during the input of the description the
maxsize is set to <= EXDSCR_LENGTH, which goes wrong because there
is no room for the '\0' terminator. Instead of terminating the
description, it terminates the title (which lies behind the
description). It could even be that on some os-es it causes a
segfault, but om Solaris 2.6 with the newest GCC it just overwrites
the next string.

Extending the structure causes a playerfile corruption, so another
solution is necesary. I thought (well, not much thinking needed)
of the following fix.

in interpreter.c in the function nanny():
search for the lines containing :
        d->str = &d->character->player.description;
        d->max_str = EXDSCR_LENGTH;
change the last line to :
        d->max_str = EXDSCR_LENGTH-1;

And to fix damaged characters go to db.c in the function char_to_store():
search for the lines containing:
        if (ch->player.description)
                strcpy(st->description, ch->player.description);
make these lines :
        if (ch->player.description)
                {
                strncpy(st->description, ch->player.description, EXDSCR_LENGTH-1);
                st->description[EXDSCR_LENGTH-1] = '\0';
                }

This character fix will make characters to set and save their title
again, because the just before players go in game the MUD does
a 'save_char(<character>, NOWHERE)'.

This should fix the problem. I've checked this with pl12 and pl15, and
the bug was in the both of them.

Greetings,
Aragorn

Try : imagica.net 4000 and be amazed.

--
In days long gone, the captain used to go down with his ship.  Now that
Windows NT is running Navy warships, the ships go down all by themselves.


     +------------------------------------------------------------+
     | 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