Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 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
LoP 1.46
Author: Remcon
Submitted by: Remcon
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
Users Online
CommonCrawl, Google, DotBot, Bing

Members: 0
Guests: 8
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
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,639
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 >>