Wiznet Bug?

From: Mud Person (mud@friley68.res.iastate.edu)
Date: 09/28/94


I think my friend has found a bug in the wiznet command.  Specifically,
when you use the #level option, it will truncate the first character
of the string that you wished to send.  For example:

> wiznet #34 ABCDEF

sends out the string "BCDEF"

I think I've found the actual bug and put together a fix for it.

The problem seems to be located in act.wizard.c at the following line:

 half_chop(++argument, buf1, argument);

My newbie guess is that the problem is some sort of side effect caused
by using both argument and ++argument in the call.  The 3rd argument
is what is finally output to players.  The 1st argument just shifts
the string to remove the starting '#' character.

My "newbie" fix follows:

in variable declarations for ACMD(do_wiznet) add the following:

char* temp;    /* Temp variable to fix bug in Case '#':   - DVT */

Next, in case '#' change

    if (is_number(buf1)) {
      half_chop(++argument, buf1, argument);
      level = MAX(atoi(buf1), LVL_IMMORT);
      if (level > GET_LEVEL(ch)) {
        send_to_char("You can't wizline above your own level.\r\n", ch);
        return;
      }

to be

    if (is_number(buf1)) {
      temp = argument;
      temp++;
/*    half_chop(++argument, buf1, argument);               Old version - DVT */
      half_chop(temp, buf1, argument);
      level = MAX(atoi(buf1), LVL_IMMORT);
      if (level > GET_LEVEL(ch)) {
        send_to_char("You can't wizline above your own level.\r\n", ch);
        return;
      }

This change appears to fix the problem, but I'd love some feedback from
some C gurus.  Is the fix a "good" fix or do I not seem to have a grasp
on the REAL problem.  I am not a proficient C programmer by any means.
It took me a while just to get Xxgbd running to try and debug the problem. :-)

Let me know what you pros think.

Thanks,

-=- Dan Toft

PS Thanks to my friend Dave who actually spooted the problem!



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