Re: [BUG] Stock bug in player descriptions

From: George Greer (greerga@circlemud.org)
Date: 04/16/99


On Thu, 15 Apr 1999, Martijn Schoemaker wrote:

>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';
>                }

Not the best way to fix it.

In modify.c:

    if (strlen(str) + strlen(*d->str) > d->max_str) {
      send_to_char("String too long.  Last line skipped.\r\n", d->character);
      terminator = 1;
    } else {
      if (!(*d->str = (char *) realloc(*d->str, strlen(*d->str) + strlen(str) + 3))) {
        perror("SYSERR: string_add");
        exit(1);
      }
      strcat(*d->str, str);
    }

Change[1] that first line to:

  if (strlen(str) + strlen(*d->str) + 1 > d->max_str) {

Always fix the cause, not the symptom.

--
George Greer            | The CircleMUD FAQ
greerga@circlemud.org   | http://developer.circlemud.org/docs/FAQ/

[1] I _think_ that's right.  It makes perfect sense to me right now.
    Then again, I've been drudging through modify.c's string_add() for
    about an hour now trying to convince it to accept the OasisOLC v2.0
    editing changes.  That function is just way too unwieldly right now.


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