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, Yandex, Sogou, Google

Members: 0
Guests: 11
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 » SmaugFUSS Bugfix List » [Bug] Several formatting tags...
Forum Rules | Mark all | Recent Posts

[Bug] Several formatting tags are setup improperly
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 14, 2005, 6:40 pm   Last edited Sep 15, 2005, 6:13 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: Several formatting tags are setup improperly.
Danger: Medium - These things can cause unpredictable results.
Found by: GCC/Samson
Fixed by: Samson

---

act_comm.c, do_repeat

Locate:
   if( ch->pcdata->tell_history[tindex] )
   {
      set_char_color( AT_TELL, ch );
      ch_printf( ch, ch->pcdata->tell_history[tindex] );
   }
   else
   {
      ch_printf( ch, "No one like that has sent you a tell.\n\r" );
   }

   return;


Change to:
   if( ch->pcdata->tell_history[tindex] )
   {
      set_char_color( AT_TELL, ch );
      send_to_char( ch->pcdata->tell_history[tindex], ch );
   }
   else
   {
      send_to_char( "No one like that has sent you a tell.\n\r", ch );
   }
   return;


act_wiz.c, do_mstat

Locate:
    pager_printf_color( ch, "&cClass  : &w%-2.2d/%-10s   &cRace      : &w%-2.2d/%-10s\n\r",
	victim->class,
        IS_NPC(victim)?victim->class<MAX_NPC_CLASS&&victim->class>=0?
        npc_class[victim->class] : "unknown":victim->class<MAX_PC_CLASS&&
        class_table[victim->class]->who_name&&
        class_table[victim->class]->who_name[0] != '\0'?
	class_table[victim->class]->who_name:"unknown",
	victim->race,
	IS_NPC(victim)?victim->race<MAX_NPC_RACE&&victim->race>=0?
        npc_race[victim->race] : "unknown":victim->race<MAX_PC_RACE&&
        race_table[victim->race]->race_name&&
        race_table[victim->race]->race_name[0] != '\0'?
        race_table[victim->race]->race_name:"unknown",
	  npc_race[victim->race],
	  victim->position );


Change to:
   pager_printf_color( ch, "&cclass  : &w%-2.2d/%-10s   &cRace      : &w%-2.2d/%-10s\n\r",
                       victim->Class,
                       IS_NPC( victim ) ? victim->Class < MAX_NPC_CLASS && victim->Class >= 0 ?
                       npc_class[victim->Class] : "unknown" : victim->Class < MAX_PC_CLASS &&
                       class_table[victim->Class]->who_name &&
                       class_table[victim->Class]->who_name[0] != '\0' ?
                       class_table[victim->Class]->who_name : "unknown",
                       victim->race,
                       IS_NPC( victim ) ? victim->race < MAX_NPC_RACE && victim->race >= 0 ?
                       npc_race[victim->race] : "unknown" : victim->race < MAX_PC_RACE &&
                       race_table[victim->race]->race_name &&
                       race_table[victim->race]->race_name[0] != '\0' ?
                       race_table[victim->race]->race_name : "unknown" );


do_strip

Locate:
   if( !count )
      pager_printf_color( ch, "&GNothing found to take.\n\r", ch );


Change to:
   if( !count )
      send_to_pager( "&GNothing found to take.\n\r", ch );


save_watchlist

Locate:
   if( !( fp = fopen( SYSTEM_DIR WATCH_LIST, "w" ) ) )
   {
      bug( "Save_watchlist: Cannot open %s" WATCH_LIST );
      perror( WATCH_LIST );
      return;
   }


Change to:
   if( !( fp = fopen( SYSTEM_DIR WATCH_LIST, "w" ) ) )
   {
      bug( "Save_watchlist: Cannot open %s", WATCH_LIST );
      perror( WATCH_LIST );
      return;
   }


save_reserved

Locate:
   if( !( fp = fopen( SYSTEM_DIR RESERVED_LIST, "w" ) ) )
   {
      bug( "Save_reserved: cannot open %s" RESERVED_LIST );
      perror( RESERVED_LIST );
      return;
   }


Change to:
   if( !( fp = fopen( SYSTEM_DIR RESERVED_LIST, "w" ) ) )
   {
      bug( "Save_reserved: cannot open %s", RESERVED_LIST );
      perror( RESERVED_LIST );
      return;
   }


boards.c, do_note

Locate:
         for( pnote = board->first_note; pnote; pnote = pnote->next )
            if( is_note_to( ch, pnote ) || get_trust( ch ) >= sysdata.read_all_mail )
               ch_printf( ch, "%2d%c %-12s: %-13s : %s\n\r",
                          ++vnum, is_note_to( ch, pnote ) ? '-' : '}', pnote->sender, pnote->subject );


Change to:
         for( pnote = board->first_note; pnote; pnote = pnote->next )
            if( is_note_to( ch, pnote ) || get_trust( ch ) >= sysdata.read_all_mail )
               ch_printf( ch, "%2d%c %-12s: %-13s : %s\n\r",
                          ++vnum, is_note_to( ch, pnote ) ? '-' : '}', pnote->sender, pnote->subject, pnote->text );


db.c, load_area_file

Locate:
   if( ( fpArea = fopen( filename, "r" ) ) == NULL )
   {
      perror( filename );
      bug( "load_area: error loading file (can't open)" );
      bug( filename );
      return;
   }


Change to:
   if( ( fpArea = fopen( filename, "r" ) ) == NULL )
   {
      perror( filename );
      bug( "load_area: error loading file (can't open) %s", filename );
      return;
   }


Locate:
      if( fread_letter( fpArea ) != '#' )
      {
         bug( tarea->filename );
         bug( "load_area: # not found." );
         exit( 1 );
      }


Change to:
      if( fread_letter( fpArea ) != '#' )
      {
         bug( "%s: #not found", __FUNCTION__ );
         exit( 1 );
      }


Locate:
      else
      {
         bug( tarea->filename );
         bug( "load_area: bad section name." );
         if( fBootDb )
            exit( 1 );
         else
         {
            fclose( fpArea );
            fpArea = NULL;
            return;
         }
      }


Change to:
      else
      {
         bug( "%s: bad section name: %s", __FUNCTION__, word );
         if( fBootDb )
            exit( 1 );
         else
         {
            fclose( fpArea );
            fpArea = NULL;
            return;
         }
      }


fight.c, group_gain

Locate:
   if( members == 0 )
   {
      bug( "Group_gain: members.", members );
      members = 1;
   }


Change to:
   if( members == 0 )
   {
      bug( "%s: members %d", __FUNCTION__, members );
      members = 1;
   }


interp.c, do_timecmd

Locate:
   ch_printf( ch, "Timing took %d.%06d seconds.\n\r", etime.tv_sec, etime.tv_usec );


Change to:
   ch_printf( ch, "Timing took %ld.%06ld seconds.\n\r", (time_t)etime.tv_sec, (time_t)etime.tv_usec );


send_timer

Locate:
   ch_printf( ch, "Time (in secs): min %d.%0.6d; avg: %d.%0.6d; max %d.%0.6d"
              "\n\r", vtime->min_time.tv_sec, vtime->min_time.tv_usec, ntime.tv_sec,
              ntime.tv_usec, vtime->max_time.tv_sec, vtime->max_time.tv_usec );


Change to:
   ch_printf( ch, "Time (in secs): min %ld.%06ld; avg: %ld.%06ld; max %ld.%06ld"
              "\n\r", vtime->min_time.tv_sec, vtime->min_time.tv_usec, ntime.tv_sec,
              ntime.tv_usec, vtime->max_time.tv_sec, vtime->max_time.tv_usec );


save.c, fread_mobile

Locate:
      if( !fMatch )
      {
         bug( "%s: no match: ", __FUNCTION__, word );
         fread_to_eol( fp );
      }


Change to:
      if( !fMatch )
      {
         bug( "%s: no match: %s", __FUNCTION__, word );
         fread_to_eol( fp );
      }


tables.c, save_herb_table

Locate:
   if( ( fpout = fopen( HERB_FILE, "w" ) ) == NULL )
   {
      bug( "Cannot open %s for writting" HERB_FILE );
      perror( HERB_FILE );
      return;
   }


Change to:
   if( !( fpout = fopen( HERB_FILE, "w" ) ) )
   {
      bug( "Cannot open %s for writting", HERB_FILE );
      perror( HERB_FILE );
      return;
   }


load_socials

Locate:
   else
   {
      bug( "Cannot open %s" SOCIAL_FILE );
      exit( 0 );
   }


Change to:
   else
   {
      bug( "Cannot open %s", SOCIAL_FILE );
      exit( 0 );
   }


load_commands

Locate:
   else
   {
      bug( "Cannot open %s" COMMAND_FILE );
      exit( 0 );
   }


Change to:
   else
   {
      bug( "Cannot open %s", COMMAND_FILE );
      exit( 0 );
   }


update.c, update_handler

Locate:
      ch_printf( timechar, "Timing took %d.%06d seconds.\n\r", etime.tv_sec, etime.tv_usec );
      timechar = NULL;


Change to:
      ch_printf( timechar, "Timing took %ld.%06ld seconds.\n\r", (time_t)etime.tv_sec, (time_t)etime.tv_usec );
      timechar = NULL;


weather_update

Locate:
         set_char_color( weath->echo_color, d->character );
         ch_printf( d->character, weath->echo );


Change to:
         set_char_color( weath->echo_color, d->character );
         send_to_char( weath->echo, d->character );


time_update

Locate:
         set_char_color( weath->echo_color, d->character );
         ch_printf( d->character, weath->echo );


Change to:
         set_char_color( weath->echo_color, d->character );
         send_to_char( weath->echo, d->character );


The above set of fixes all involve the -Wformat-security warning flag. For a function to trip the warning, it needs to use one of the va_list tags, like how ch_printf does, and it needs to have an __attribute__ tag on the declaration of the function in mud.h. Once these two conditions are met, the code will pop out warnings on these. Fixing them is highly advisable. In order to catch these, you'd need something like:

void ch_printf( CHAR_DATA * ch, char *fmt, ... ) __attribute__ ( ( format( printf, 2, 3 ) ) );


The mud.h file in the distro has all of the proper attribute settings done. The list of things to change would have become quite lengthy but it is worth the time to check them.

Keep in mind - this only fixes the things the compiler actually issued warnings for. There are a whole bunch of other uses of these kinds of things that are just as wrong but still appear to be safe.
       
Pages:<< prev 1 next >>