Re: Olc, ASCII pfile, player char data... :P

From: Daniel A. Koepke (
Date: 11/23/99

On Tue, 23 Nov 1999, Emil Nilimaa wrote:

> [snip]

I'm guessing that we're dealing with a memory/buffer overflow, but I can't
be certain of that right off.  Anyway, there's only one way to find
out: check the code.

>   int rec_count = 0, i;
>   FBFILE *plr_index;
>   char index_name[40], line[256], bits[64];
>   char arg2[80];
>   sprintf(index_name, "%s", PLR_INDEX_FILE);

I don't suppose PLR_INDEX_FILE is more than 39 characters long?

>   if(!(plr_index = fbopen(index_name, FB_READ))) {
>     top_of_p_table = -1;
>     log("No player index file!  First new char will be IMP!");
>     return;
>   }

Ensure that fbopen() doesn't attempt to copy the filename to a buffer too

>   /* count the number of players in the index */
>   while(fbgetline(plr_index, line))

In gdb, switch to the frame where this call is made (e.g., "frame 0" to
switch to #0 in the backtrace, "frame 1" to switch to #1, etc.) and "print
*plr_index".  Also do, "print line".

> int fbgetline(FBFILE *fbfl, char *line)
> {

Switch to the frame where we're in this function (it's the line with the
crash, yes?) and try:

    print *fbfl
    print line
    print r
    print fbfl->buf
    print fbfl->size
    print w

Look for anything that seems wrong.  For instance, when printing the
contents of a character array, junk characters *before* a '\0'; for a
pointer, a NULL address (0x0); if fbfl->size is considerably longer than
fbfl->buf, etc.

Of course, the interactive debugging process is considerably easier to do,
so if none of this really helps you, I would suggest looking into GDB
documentation (Ceramic Mouse has some, I believe).  If you think you've
tracked down the problem, but don't know how to fix it, well, try fixing
it first (keep backups :).  That's also your second and third and fourth
task.  Around the fifth or sixth time, ask and maybe someone will help. :)


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

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