Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CF: A bug (and a fix)



We (if you guys still remember us) are setting the CF up here again,
and are using crossfire-0.93.5 with cmb4. I immediately found one bug, doing
"telnet localhost 13326" and writing "help" crashes crossfire.

Program received signal SIGSEGV, Segmentation fault.
0x806a674 in parse_command (op=0x0, str=0xbfffe9a8 "help") at commands.c:873
873             op->contr->input_buf[0]=0;
(gdb) bt
#0  0x806a674 in parse_command (op=0x0, str=0xbfffe9a8 "help")
    at commands.c:873
#1  0x809aded in check_socket () at socket.c:216
#2  0x8079b94 in main (argc=2, argv=0xbffffaec) at main.c:890
#3  0x804a91b in _start ()
(gdb)

I think this was introduced with the "can write long lines" patch, as this
bug has only recently appeared. I think that adding the "if(op)" check
there is the correct way to fix the bug, as if op==0 it's a socket and it
doesn't have a controlling object or an input buffer :)

Here is the patch:

*** server/commands.c.old       Thu Sep  4 09:11:25 1997
--- server/commands.c   Thu Sep  4 09:14:59 1997
***************
*** 870,876 ****
         * clear the buffer, and then return the value.
         */
        i=parse_string(op,str);
!       op->contr->input_buf[0]=0;
        return i;
    }
    return 0;
--- 870,876 ----
         * clear the buffer, and then return the value.
         */
        i=parse_string(op,str);
!       if(op) op->contr->input_buf[0]=0;
        return i;
    }
    return 0;
[to unsubscribe etc., send mail to crossfire-request@ifi.uio.no]