Login
User Name:

Password:



Register

Forgot your password?
 Overland with Bitmaps
Jul 4, 2025 11:57 pm
By Samson
void nanny_get_new_race -- comm.c
Mar 13, 2025 7:08 am
By Elwood
IPv6
Jan 25, 2025 10:45 pm
By Samson
mudstrlcpy and mudstrlcat
Jan 18, 2025 5:23 pm
By Samson
I3 and IMC
Jan 17, 2025 9:35 pm
By Samson
SWFotEFUSS 1.5.3
Author: Various
Submitted by: Samson
SWRFUSS 1.4.3
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.8
Author: Various
Submitted by: Samson
AFKMud 2.5.2
Author: AFKMud Team
Submitted by: Samson
SmaugFUSS 1.9.7
Author: Various
Submitted by: Samson
Users Online
Anthropic, Majestic-12, AhrefsBot, Amazonbot, DotBot

Members: 0
Guests: 5
Stats
Files
Topics
Posts
Members
Newest Member
507
3,812
19,725
595
VelmaThoms

» 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,708
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 >>