Login
User Name:

Password:



Register

Forgot your password?
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
SWRFUSS 1.4
Author: Various
Submitted by: Samson
Users Online
Google, DotBot

Members: 0
Guests: 34
Stats
Files
Topics
Posts
Members
Newest Member
488
3,788
19,631
595
Khonsu

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Bugfix Lists » AFKMud Bugfix List » [Bug] Help file loader does n...
Forum Rules | Mark all | Recent Posts

[Bug] Help file loader does not recognize a corrupted helps.dat file
< Newer Topic :: Older Topic > AFKMud 2.02

Pages:<< prev 1 next >>
Post is unread #1 Oct 14, 2007 12:19 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Bug: Help file loader does not recognize a corrupted helps.dat file
Danger: Critical - Continuing to parse a corrupted file leaves undefined results in memory. Can also lead to data loss.
Discovered in: AFKMud 2.02
Found by: Toadvile
Fixed by: Samson

---

help.cpp, load_helps

Locate:
      if( key == "#HELP" )
         help = new help_data;

      if( key == "Keywords" )
      {
         stream.getline( buf, MSL );
         value = buf;
         strip_lspace( value );
         help->keyword = str_dup( value.c_str() );
      }

      if( key == "Level" )
      {
         stream.getline( buf, MSL );
         value = buf;
         strip_lspace( value );

         help->level = atoi( value.c_str() );
      }

      if( key == "Text" )
      {
         stream.getline( buf, MSL, '¢' );
         value = buf;
         strip_lspace( value );
         help->text = str_dup( value.c_str() );
      }

      if( key == "End" )
         helplist.push_back( help );


Change to:
      if( key == "#HELP" )
         help = new help_data;

      else if( key == "Keywords" )
      {
         stream.getline( buf, MSL );
         value = buf;
         strip_lspace( value );
         help->keyword = str_dup( value.c_str() );
      }

      else if( key == "Level" )
      {
         stream.getline( buf, MSL );
         value = buf;
         strip_lspace( value );

         help->level = atoi( value.c_str() );
      }

      else if( key == "Text" )
      {
         stream.getline( buf, MSL, '¢' );
         value = buf;
         strip_lspace( value );
         help->text = str_dup( value.c_str() );
      }

      else if( key == "End" )
         helplist.push_back( help );

      else
      {
         stream.getline( buf, MSL );
         value = buf;
         strip_lspace( value );
         log_printf( "Bad line in help file: %s %s", key.c_str(), value.c_str() );
      }


Because this routine was poorly written ( I'm still rather new to C++ and file streams ) it would not cause any log messages to appear about a corrupted file format. As a result of this the mud owner/admin is led to believe there are no problems. However there is a very real possibility of incomplete data being saved back to the helps.dat file causing data loss. The undetected corrupted help entry could also lead to a game crash if it's accessed.

The related corrupt help entry which led to this bug's discovery should be repaired as well:

#HELP
Level 104
Keywords LIQUIDTYPES
Text Liquid Type
------------------------------
water
beer
wine
ale
dark ale
whiskey
lemonade
firebreather
local specialty
slime mold juice
milk
tea
coffee
blood
salt water
cola
mead
grog
orange juice
vodka

See also: OSET, ITEMVALUES.
¢
End

Pages:<< prev 1 next >>