Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl

Members: 0
Guests: 2
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] check_bans never initia...
Forum Rules | Mark all | Recent Posts

[Bug] check_bans never initializes the new_host variable
< Newer Topic :: Older Topic > AFKMud 1.63

Pages:<< prev 1 next >>
Post is unread #1 Apr 24, 2004, 11:44 am   Last edited Nov 13, 2005, 12:16 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Bug: check_bans never initializes the new_host variable
Discovered in: AFKMud 1.63
Danger: Medium - Undefined behaviour
Found by: Valgrind
Fixed by: Samson

ban.c, check_bans:

replace the check_bans function with:

/*
 * The workhose, checks for bans. Shaddai
 */
bool check_bans( CHAR_DATA *ch )
{
   BAN_DATA *pban;
   char new_host[MSL];
   bool fMatch = FALSE;
   int i;

   for( i = 0; i < (int)( strlen( ch->desc->host ) ); i++ )
      new_host[i] = LOWER( ch->desc->host[i] );
         new_host[i] = '\0';

   for( pban = first_ban; pban; pban = pban->next )
   {
      if( pban->prefix && pban->suffix && strstr( pban->name, new_host ) )
         fMatch = TRUE;
      else if( pban->prefix && !str_suffix( pban->name, new_host ) )
         fMatch = TRUE;
      else if( pban->suffix && !str_prefix( pban->name, new_host ) )
         fMatch = TRUE;
      else if( !str_cmp( pban->name, new_host ) )
         fMatch = TRUE;
      else
         fMatch = FALSE;
      if( fMatch )
      {
         if( check_expire( pban ) )
         {
            dispose_ban( pban );
            save_banlist( );
            return FALSE;
         }
         if( ch->level > pban->level )
         {
            if( pban->warn )
               log_printf( "%s logging in from site %s.", ch->name, ch->desc->host );
            return FALSE;
         }
         else
            return TRUE;
      }
   }
   return FALSE;
}


This is what one calls a stupid mistake. Somewhere during the stripping of the useless class/race/etc bans to make this only go by sites, I forgot to check to make sure the part where new_host is filled got handled. So it was doing a str_cmp on an undefined variable. With undefined results. Oops.
       
Pages:<< prev 1 next >>