Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
Google, AhrefsBot

Members: 0
Guests: 19
Stats
Files
Topics
Posts
Members
Newest Member
489
3,793
19,649
597
Aileenutz

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] Adding a room affect fa...
Forum Rules | Mark all | Recent Posts

[Bug] Adding a room affect fails under most conditions
< Newer Topic :: Older Topic > AFKMud 1.77

Pages:<< prev 1 next >>
Post is unread #1 Oct 9, 2006 2:44 am   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Bug: Adding a room affect fails under most conditions
Danger: Medium - Code makes use of uninitialized variables
Discovered in: AFKMud 1.77
Found by: Samson
Fixed by: Samson

---

build.c, do_redit

Locate:
      else if( loc == APPLY_RESISTANT || loc == APPLY_IMMUNE || loc == APPLY_SUSCEPTIBLE || loc == APPLY_ABSORB )
      {
         char *risa = arg3;
         char flag[MIL];

         while( risa[0] != '\0' )
         {
            risa = one_argument( risa, flag );
            value = get_risflag( flag );

            if( value < 0 || value >= MAX_RIS_FLAG )
               ch_printf( ch, "Unknown flag: %s\n\r", flag );
            else
            {
               xSET_BIT( risabit, value );
               found = true;
            }
         }
      }
      else if( loc == APPLY_WEAPONSPELL
               || loc == APPLY_WEARSPELL
               || loc == APPLY_REMOVESPELL || loc == APPLY_STRIPSN || loc == APPLY_RECURRINGSPELL || loc == APPLY_EAT_SPELL )
      {
         value = skill_lookup( arg3 );

         if( !IS_VALID_SN( value ) )
            ch_printf( ch, "Invalid spell: %s", arg3 );
         else
            found = true;
      }
      else
      {
         value = atoi( arg3 );
         found = true;
      }
      if( !found )
         return;


Change to:
      else if( loc == APPLY_RESISTANT || loc == APPLY_IMMUNE || loc == APPLY_SUSCEPTIBLE || loc == APPLY_ABSORB )
      {
         char *risa = argument;
         char flag[MIL];

         while( risa[0] != '\0' )
         {
            risa = one_argument( risa, flag );
            value = get_risflag( flag );

            if( value < 0 || value >= MAX_RIS_FLAG )
               ch_printf( ch, "Unknown flag: %s\n\r", flag );
            else
            {
               xSET_BIT( risabit, value );
               found = true;
            }
         }
      }
      else if( loc == APPLY_WEAPONSPELL
               || loc == APPLY_WEARSPELL
               || loc == APPLY_REMOVESPELL || loc == APPLY_STRIPSN || loc == APPLY_RECURRINGSPELL || loc == APPLY_EAT_SPELL )
      {
         value = skill_lookup( argument );

         if( !IS_VALID_SN( value ) )
            ch_printf( ch, "Invalid spell: %s", argument );
         else
            found = true;
      }
      else
      {
         value = atoi( argument );
         found = true;
      }
      if( !found )
         return;


Most of the flag checking in the redit command for adding room affects is seriously flawed. The flags are checked via the arg3 string, which is never initialized to anything before reaching this point in the function. So it will be attempting to apply affects which were not intended because the value of arg3 is unpredictable. This bug is likely the result of previous work done to reduce the use of static char[] string declarations for memory saving.

Pages:<< prev 1 next >>