Changeset 1437

Show
Ignore:
Timestamp:
06/13/09 10:00:32 (15 months ago)
Author:
ajps
Message:

Fix spell description bug reported by Timo on rgra. Sorts out various uses of text_out to prevent strings read from files or generated by the game being used as format strings.

Location:
trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/cmd-know.c

    r1381 r1437  
    14021402        { 
    14031403                int x, y; 
    1404                 text_out(e_text + e_ptr->text); 
     1404                text_out("%s", e_text + e_ptr->text); 
    14051405                Term_locate(&x, &y); 
    14061406                Term_gotoxy(0, y+1); 
  • trunk/src/cmd5.c

    r1436 r1437  
    470470        text_out("\n\n   "); 
    471471 
    472         text_out(s_text + s_info[(cp_ptr->spell_book == TV_MAGIC_BOOK) ? spell : spell + PY_MAX_SPELLS].text); 
     472        text_out("%s", s_text + s_info[(cp_ptr->spell_book == TV_MAGIC_BOOK) ? spell : spell + PY_MAX_SPELLS].text); 
    473473        text_out_c(TERM_L_BLUE, "\n\n[Press any key to continue]\n"); 
    474474 
  • trunk/src/wiz-spoil.c

    r1346 r1437  
    11/* 
    2  * File: wizard1.c 
     2 * File: wiz-spoil.c 
    33 * Purpose: Spoiler generation 
    44 * 
     
    5353static void spoiler_underline(cptr str, char c) 
    5454{ 
    55         text_out(str); 
     55        text_out("%s", str); 
    5656        text_out("\n"); 
    5757        spoiler_out_n_chars(strlen(str), c); 
     
    505505                         * its weight, and its value in gold pieces. 
    506506                         */ 
    507                         text_out(format("\nLevel %u, Rarity %u, %d.%d lbs, %ld AU\n", 
    508                                         a_ptr->level, a_ptr->rarity, (a_ptr->weight / 10), 
    509                                         (a_ptr->weight % 10), ((long)a_ptr->cost))); 
     507                        text_out("\nLevel %u, Rarity %u, %d.%d lbs, %ld AU\n", 
     508                                        a_ptr->level, a_ptr->rarity, (a_ptr->weight / 10), 
     509                                         (a_ptr->weight % 10), ((long)a_ptr->cost)); 
    510510 
    511511                        /* Terminate the entry */ 
     
    697697 
    698698        /* Dump the header */ 
    699         strnfmt(buf, sizeof(buf), "Monster Spoilers for %s Version %s\n", 
     699        text_out("Monster Spoilers for %s Version %s\n", 
    700700                VERSION_NAME, VERSION_STRING); 
    701         text_out(buf); 
    702701        text_out("------------------------------------------\n\n"); 
    703702 
     
    744743 
    745744                /* Name */ 
    746                 strnfmt(buf, sizeof(buf), "%s  (", (r_name + r_ptr->name));     /* ---)--- */ 
    747                 text_out(buf); 
     745                text_out("%s  (", (r_name + r_ptr->name));      /* ---)--- */ 
    748746 
    749747                /* Color */ 
     
    751749 
    752750                /* Symbol --(-- */ 
    753                 strnfmt(buf, sizeof(buf), " '%c')\n", r_ptr->d_char); 
    754                 text_out(buf); 
     751                text_out(" '%c')\n", r_ptr->d_char); 
    755752 
    756753 
     
    759756 
    760757                /* Number */ 
    761                 strnfmt(buf, sizeof(buf), "Num:%d  ", r_idx); 
    762                 text_out(buf); 
     758                text_out("Num:%d  ", r_idx); 
    763759 
    764760                /* Level */ 
    765                 strnfmt(buf, sizeof(buf), "Lev:%d  ", r_ptr->level); 
    766                 text_out(buf); 
     761                text_out("Lev:%d  ", r_ptr->level); 
    767762 
    768763                /* Rarity */ 
    769                 strnfmt(buf, sizeof(buf), "Rar:%d  ", r_ptr->rarity); 
    770                 text_out(buf); 
     764                text_out("Rar:%d  ", r_ptr->rarity); 
    771765 
    772766                /* Speed */ 
    773767                if (r_ptr->speed >= 110) 
    774768                { 
    775                         strnfmt(buf, sizeof(buf), "Spd:+%d  ", (r_ptr->speed - 110)); 
     769                        text_out("Spd:+%d  ", (r_ptr->speed - 110)); 
    776770                } 
    777771                else 
    778772                { 
    779                         strnfmt(buf, sizeof(buf), "Spd:-%d  ", (110 - r_ptr->speed)); 
    780                 } 
    781                 text_out(buf); 
     773                        text_out("Spd:-%d  ", (110 - r_ptr->speed)); 
     774                } 
    782775 
    783776                /* Hitpoints */ 
    784                 strnfmt(buf, sizeof(buf), "Hp:%d  ", r_ptr->avg_hp); 
    785                 text_out(buf); 
     777                text_out("Hp:%d  ", r_ptr->avg_hp); 
    786778 
    787779                /* Armor Class */ 
    788                 strnfmt(buf, sizeof(buf), "Ac:%d  ", r_ptr->ac); 
    789                 text_out(buf); 
     780                text_out("Ac:%d  ", r_ptr->ac); 
    790781 
    791782                /* Experience */ 
    792                 strnfmt(buf, sizeof(buf), "Exp:%ld\n", (long)(r_ptr->mexp)); 
    793                 text_out(buf); 
     783                text_out("Exp:%ld\n", (long)(r_ptr->mexp)); 
    794784 
    795785                /* Describe */ 
  • trunk/src/xtra3.c

    r1417 r1437  
    16681668                while (file_getl(fp, buf, sizeof(buf))) 
    16691669                { 
    1670                         text_out_e(buf); 
     1670                        text_out_e("%s", buf); 
    16711671                        text_out("\n"); 
    16721672                }