Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, DotBot

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SWFOTE FUSS Bugfix List » [Bug] mset command allows NPC...
Forum Rules | Mark all | Recent Posts

[Bug] mset command allows NPC flag to be set on players
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Apr 17, 2005, 12:34 am   Last edited May 23, 2005, 9:19 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: mset command allows NPC flag to be set on players
Danger: Critical - Crash bug. Abuse potential involved.
Found by: Halcyon
Fixed by: Samson

---

build.c, do_mset

Locate:
   if( !str_cmp( arg2, "flags" ) )
   {
      bool pcflag;
      if( !IS_NPC( victim ) && get_trust( ch ) < LEVEL_GREATER )
      {
         send_to_char( "You can only modify a mobile's flags.\n\r", ch );
         return;
      }

      if( !can_mmodify( ch, victim ) )
         return;
      if( !argument || argument[0] == '' )
      {
         send_to_char( "Usage: mset <victim> flags <flag> [flag]...\n\r", ch );
         return;
      }
      while( argument[0] != '' )
      {
         pcflag = FALSE;
         argument = one_argument( argument, arg3 );
         value = IS_NPC( victim ) ? get_actflag( arg3 ) : get_plrflag( arg3 );

         if( !IS_NPC( victim ) && ( value < 0 || value > MAX_BITS ) )
         {
            pcflag = TRUE;
            value = get_pcflag( arg3 );
         }
         if( value < 0 || value > MAX_BITS )
            ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
         else
         {
            if( IS_NPC( victim )
                && value == ACT_PROTOTYPE
                && get_trust( ch ) < LEVEL_GREATER && !is_name( "protoflag", ch->pcdata->bestowments ) )
               send_to_char( "You cannot change the prototype flag.\n\r", ch );
            else if( IS_NPC( victim ) && value == ACT_IS_NPC )
               send_to_char( "If that could be changed, it would cause many problems.\n\r", ch );
            else
            {
               if( pcflag )
                  TOGGLE_BIT( victim->pcdata->flags, 1 << value );
               else
               {
                  xTOGGLE_BIT( victim->act, value );
                  /*
                   * NPC check added by Gorog 
                   */
                  if( IS_NPC( victim ) && value == ACT_PROTOTYPE )
                     victim->pIndexData->act = victim->act;
               }
            }
         }
      }
      if( IS_NPC( victim ) && xIS_SET( victim->act, ACT_PROTOTYPE ) )
         victim->pIndexData->act = victim->act;
      return;
   }


Change to:
  if( !str_cmp( arg2, "flags" ) )
  {
      bool protoflag = FALSE, ftoggle = FALSE;

      if( !IS_NPC(victim) && get_trust( ch ) < LEVEL_GREATER )
      {
        send_to_char( "You can only modify a mobile's flags.\n\r", ch );
        return;
      }

      if( !argument || argument[0] == '' )
      {
        send_to_char( "Usage: mset <vic> flags <flag> [flag]...\n\r", ch );
        return;
      }

      if( IS_SET( victim->act, ACT_PROTOTYPE ) )
        protoflag = TRUE;

      while( argument[0] != '' )
      {
        argument = one_argument( argument, arg3 );

        if( IS_NPC(victim) )
        {
            value = get_actflag( arg3 );

            if( value < 0 || value >= 31 )
              ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
            else if( 1 << value == ACT_PROTOTYPE && ch->top_level < sysdata.level_modify_proto )
              send_to_char( "You cannot change the prototype flag.\n\r", ch );
            else if( 1 << value == ACT_IS_NPC )
              send_to_char( "If the NPC flag could be changed, it would cause many problems.\n\r", ch );
            else
              TOGGLE_BIT( victim->act, 1 << value );
        }
        else
        {
            value = get_plrflag( arg3 );

            if( value < 0 || value >= 31 )
              ch_printf( ch, "Unknown flag: %s\n\r", arg3 );
            else if( 1 << value == ACT_IS_NPC )
              send_to_char( "If the NPC flag could be changed, it would cause many problems.\n\r", ch );
            else
            {
               ftoggle = TRUE;
               TOGGLE_BIT( victim->act, 1 << value );
            }
         }
      }
      if( ftoggle )
         send_to_char( "Flags set.\n\r", ch );
      if( IS_SET( victim->act, ACT_PROTOTYPE ) || ( value == ACT_PROTOTYPE && protoflag ) )
         victim->pIndexData->act = victim->act;
      return;
  }


This bug appears to have been around since the stone age. Thanks to Halcyon, not anymore. The mset command was allowing a dangerous condition to get through and allowed the NPC flag to be toggled on players. The result would be a crash within a few moments as the update_handler dutifuly assumed that the first player it encountered was an NPC and checked it for pIndexData, which players do not have. There is no need to edit the corresponding section of mpxset.c since that command is not allowed to edit PCs by default.
       
Pages:<< prev 1 next >>