Changeset 136

Show
Ignore:
Timestamp:
05/14/07 03:31:20 (1 year ago)
Author:
takkaria
Message:

Minimise use of insecure string functions (#45).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/autoconf.h.in

    r127 r136  
    3434#undef HAVE_MKSTEMP 
    3535 
     36/* Define to 1 if you have the <SDL/SDL_ttf.h> header file. */ 
     37#undef HAVE_SDL_SDL_TTF_H 
     38 
    3639/* Define to 1 if you have the `setegid' function. */ 
    3740#undef HAVE_SETEGID 
     
    4346/* Define to 1 if you have the <stdint.h> header file. */ 
    4447#undef HAVE_STDINT_H 
    45  
    46 /* Define to 1 if you have the <stdbool.h> header file. */ 
    47 #undef HAVE_STDBOOL_H 
    4848 
    4949/* Define to 1 if you have the <stdlib.h> header file. */ 
     
    8282/* Define to 1 if you have the <unistd.h> header file. */ 
    8383#undef HAVE_UNISTD_H 
    84  
    85 /* Define to 1 if you have the `usleep' function. */ 
    86 #undef HAVE_USLEEP 
    8784 
    8885/* Define to 1 if `lstat' dereferences a symlink specified with a trailing 
     
    153150   first (like Motorola and SPARC, unlike Intel and VAX). */ 
    154151#undef WORDS_BIGENDIAN 
    155  
    156 /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>, 
    157    <pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the 
    158    #define below would cause a syntax error. */ 
    159 #undef _UINT32_T 
    160  
    161 /* Define to the type of a signed integer type of width exactly 16 bits if 
    162    such a type exists and the standard includes do not define it. */ 
    163 #undef int16_t 
    164  
    165 /* Define to the type of a signed integer type of width exactly 32 bits if 
    166    such a type exists and the standard includes do not define it. */ 
    167 #undef int32_t 
    168  
    169 /* Define to the type of an unsigned integer type of width exactly 16 bits if 
    170    such a type exists and the standard includes do not define it. */ 
    171 #undef uint16_t 
    172  
    173 /* Define to the type of an unsigned integer type of width exactly 32 bits if 
    174    such a type exists and the standard includes do not define it. */ 
    175 #undef uint32_t 
  • trunk/src/birth.c

    r135 r136  
    775775        else if (oid == 1) 
    776776            str = "Autoroller"; 
    777         else if (oid == 2) 
     777        else 
    778778            str = "Standard roller"; 
    779779 
     
    12291229 
    12301230                        /* Extract a textual format */ 
    1231                         /* cnv_stat(m, inp); */ 
     1231                        /* cnv_stat(m, inp, sizeof(buf); */ 
    12321232 
    12331233                        /* Above 18 */ 
     
    12621262 
    12631263                                /* Default */ 
    1264                                 strcpy(inp, "")
     1264                                inp[0] = '\0'
    12651265 
    12661266                                /* Get a response (or escape) */ 
     
    13241324 
    13251325                                /* Put the stat */ 
    1326                                 cnv_stat(stat_limit[i], buf); 
     1326                                cnv_stat(stat_limit[i], buf, sizeof(buf)); 
    13271327                                c_put_str(TERM_L_BLUE, buf, 3+i, col+5); 
    13281328                        } 
     
    13801380                                        { 
    13811381                                                /* Put the stat */ 
    1382                                                 cnv_stat(stat_use[i], buf); 
     1382                                                cnv_stat(stat_use[i], buf, sizeof(buf)); 
    13831383                                                c_put_str(TERM_L_GREEN, buf, 3+i, col+24); 
    13841384 
  • trunk/src/cmd2.c

    r119 r136  
    22752275                cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): "; 
    22762276 
    2277                 char out_val[5]; 
    2278  
    2279                 /* Default */ 
    2280                 strcpy(out_val, "&"); 
     2277                char out_val[5] = "& "; 
    22812278 
    22822279                /* Ask for duration */ 
  • trunk/src/cmd3.c

    r117 r136  
    747747 
    748748        /* Start with nothing */ 
    749         strcpy(tmp, "")
     749        tmp[0] = '\0'
    750750 
    751751        /* Use old inscription */ 
     
    14241424        { 
    14251425                all = TRUE; 
    1426                 strcpy(buf, "Full monster list."); 
     1426                my_strcpy(buf, "Full monster list.", sizeof(buf)); 
    14271427        } 
    14281428        else if (sym == KTRL('U')) 
    14291429        { 
    14301430                all = uniq = TRUE; 
    1431                 strcpy(buf, "Unique monster list."); 
     1431                my_strcpy(buf, "Unique monster list.", sizeof(buf)); 
    14321432        } 
    14331433        else if (sym == KTRL('N')) 
    14341434        { 
    14351435                all = norm = TRUE; 
    1436                 strcpy(buf, "Non-unique monster list."); 
     1436                my_strcpy(buf, "Non-unique monster list.", sizeof(buf)); 
    14371437        } 
    14381438        else if (ident_info[i]) 
  • trunk/src/cmd5.c

    r24 r136  
    123123        const magic_type *s_ptr; 
    124124 
    125         cptr comment; 
    126  
     125        char help[20]; 
    127126        char out_val[160]; 
     127 
     128        const char *comment = help; 
    128129 
    129130        byte line_attr; 
     
    152153 
    153154                /* Get extra info */ 
    154                 comment = get_spell_info(cp_ptr->spell_book, spell); 
     155                get_spell_info(cp_ptr->spell_book, spell, help, sizeof(help)); 
    155156 
    156157                /* Assume spell is known and tried */ 
     
    479480        const magic_type *s_ptr; 
    480481 
    481         cptr comment; 
    482  
    483482        char out_val[160]; 
     483        char help[20]; 
     484 
     485        const char *comment = help; 
    484486 
    485487        byte line_attr; 
     
    496498 
    497499        /* Get extra info */ 
    498         comment = get_spell_info(cp_ptr->spell_book, spell); 
     500        get_spell_info(cp_ptr->spell_book, spell, help, sizeof(help)); 
    499501 
    500502        /* Assume spell is known and tried */ 
  • trunk/src/cmds.h

    r134 r136  
    44/* cmd.c */ 
    55extern void cmd_init(void); 
    6 extern void process_commands(bool no_request); 
     6extern void process_command(bool no_request); 
    77 
    88/* cmd2.c */ 
  • trunk/src/dungeon.c

    r135 r136  
    1212#include "angband.h" 
    1313#include "z-file.h" 
    14  
     14#include "cmds.h" 
    1515#include "script.h" 
    1616 
     
    18871887        if (!op_ptr->base_name[0]) 
    18881888        { 
    1889                 strcpy(op_ptr->base_name, "PLAYER"); 
     1889                my_strcpy(op_ptr->base_name, "PLAYER", sizeof(op_ptr->base_name)); 
    18901890        } 
    18911891 
     
    21362136 
    21372137                                /* Note cause of death XXX XXX XXX */ 
    2138                                 strcpy(p_ptr->died_from, "Cheating death"); 
     2138                                my_strcpy(p_ptr->died_from, "Cheating death", sizeof(p_ptr->died_from)); 
    21392139 
    21402140                                /* New depth */ 
  • trunk/src/externs.h

    r135 r136  
    235235extern cptr ANGBAND_DIR_USER; 
    236236extern cptr ANGBAND_DIR_XTRA; 
    237 extern cptr ANGBAND_DIR_SCRIPT; 
    238237extern bool item_tester_full; 
    239238extern byte item_tester_tval; 
     
    345344 
    346345/* init2.c */ 
    347 extern void init_file_paths(char *path); 
     346extern void init_file_paths(const char *path); 
    348347extern void create_user_dirs(void); 
    349348extern void init_angband(void); 
     
    673672 
    674673/* xtra1.c */ 
    675 extern void cnv_stat(int val, char *out_val); 
     674extern void cnv_stat(int val, char *out_val, size_t len); 
    676675extern s16b modify_stat_value(int value, int amount); 
    677676extern void notice_stuff(void); 
  • trunk/src/files.c

    r120 r136  
    13621362 
    13631363                /* Internal "natural" maximum value */ 
    1364                 cnv_stat(p_ptr->stat_max[i], buf); 
     1364                cnv_stat(p_ptr->stat_max[i], buf, sizeof(buf)); 
    13651365                c_put_str(TERM_L_GREEN, buf, row+i, col+5); 
    13661366 
     
    13781378 
    13791379                /* Resulting "modified" maximum value */ 
    1380                 cnv_stat(p_ptr->stat_top[i], buf); 
     1380                cnv_stat(p_ptr->stat_top[i], buf, sizeof(buf)); 
    13811381                c_put_str(TERM_L_GREEN, buf, row+i, col+24); 
    13821382 
     
    13841384                if (p_ptr->stat_use[i] < p_ptr->stat_top[i]) 
    13851385                { 
    1386                         cnv_stat(p_ptr->stat_use[i], buf); 
     1386                        cnv_stat(p_ptr->stat_use[i], buf, sizeof(buf)); 
    13871387                        c_put_str(TERM_YELLOW, buf, row+i, col+31); 
    13881388                } 
     
    20892089 
    20902090        /* Hold a string to find */ 
    2091         char finder[80]
     2091        char finder[80] = ""
    20922092 
    20932093        /* Hold a string to show */ 
    2094         char shower[80]
     2094        char shower[80] = ""
    20952095 
    20962096        /* Filename */ 
     
    20982098 
    20992099        /* Describe this thing */ 
    2100         char caption[128]
     2100        char caption[128] = ""
    21012101 
    21022102        /* Path buffer */ 
     
    21152115 
    21162116 
    2117         /* Wipe finder */ 
    2118         strcpy(finder, ""); 
    2119  
    2120         /* Wipe shower */ 
    2121         strcpy(shower, ""); 
    2122  
    2123         /* Wipe caption */ 
    2124         strcpy(caption, ""); 
    21252117 
    21262118        /* Wipe the hooks */ 
     
    24332425                if (ch == '#') 
    24342426                { 
    2435                         char tmp[80]; 
     2427                        char tmp[80] = "0"; 
     2428 
    24362429                        prt("Goto Line: ", hgt - 1, 0); 
    2437                         strcpy(tmp, "0"); 
    24382430                        if (askfor_aux(tmp, sizeof(tmp), NULL)) 
    2439                         { 
    24402431                                line = atoi(tmp); 
    2441                         } 
    24422432                } 
    24432433 
     
    24452435                if (ch == '%') 
    24462436                { 
    2447                         char ftmp[80]; 
     2437                        char ftmp[80] = "help.hlp"; 
     2438 
    24482439                        prt("Goto File: ", hgt - 1, 0); 
    2449                         strcpy(ftmp, "help.hlp"); 
    24502440                        if (askfor_aux(ftmp, sizeof(ftmp), NULL)) 
    24512441                        { 
    2452                                 if (!show_file(ftmp, NULL, 0, mode)) ch = ESCAPE; 
     2442                                if (!show_file(ftmp, NULL, 0, mode)) 
     2443                                        ch = ESCAPE; 
    24532444                        } 
    24542445                } 
     
    25912582        if (!op_ptr->base_name[0]) 
    25922583        { 
    2593                 strcpy(op_ptr->base_name, "PLAYER"); 
     2584                my_strcpy(op_ptr->base_name, "PLAYER", sizeof(op_ptr->base_name)); 
    25942585        } 
    25952586 
     
    26552646 
    26562647        /* Cause of death */ 
    2657         strcpy(p_ptr->died_from, "Quitting"); 
     2648        my_strcpy(p_ptr->died_from, "Quitting", sizeof(p_ptr->died_from)); 
    26582649} 
    26592650 
     
    26812672 
    26822673        /* The player is not dead */ 
    2683         strcpy(p_ptr->died_from, "(saved)"); 
     2674        my_strcpy(p_ptr->died_from, "(saved)", sizeof(p_ptr->died_from)); 
    26842675 
    26852676        /* Forbid suspend */ 
     
    27052696 
    27062697        /* Note that the player is not dead */ 
    2707         strcpy(p_ptr->died_from, "(alive and well)"); 
     2698        my_strcpy(p_ptr->died_from, "(alive and well)", sizeof(p_ptr->died_from)); 
    27082699} 
    27092700 
     
    27532744        FILE *fp; 
    27542745 
    2755       char str[1024]; 
     2746‰     char str[1024]; 
    27562747 
    27572748 
     
    27652756 
    27662757                        /* XXX XXX XXX "Bones" name */ 
    2767                         sprintf(tmp, "bone.%03d", p_ptr->depth); 
     2758                        strnfmt(tmp, sizeof(tmp), "bone.%03d", p_ptr->depth); 
    27682759 
    27692760                        /* Build the filename */ 
     
    36273618 
    36283619        /* Calculate and save the points */ 
    3629         sprintf(the_score.pts, "%9lu", (long)total_points()); 
     3620        strnfmt(the_score.pts, sizeof(the_score.pts), "%9lu", (long)total_points()); 
    36303621 
    36313622        /* Save the current gold */ 
    3632         sprintf(the_score.gold, "%9lu", (long)p_ptr->au); 
     3623        strnfmt(the_score.gold, sizeof(the_score.gold), "%9lu", (long)p_ptr->au); 
    36333624 
    36343625        /* Save the current turn */ 
    3635         sprintf(the_score.turns, "%9lu", (long)turn); 
     3626        strnfmt(the_score.turns, sizeof(the_score.turns), "%9lu", (long)turn); 
    36363627 
    36373628        /* Hack -- no time needed */ 
    3638         strcpy(the_score.day, "TODAY"); 
     3629        my_strcpy(the_score.day, "TODAY", sizeof(the_score.day)); 
    36393630 
    36403631        /* Save the player name (15 chars) */ 
    3641         sprintf(the_score.who, "%-.15s", op_ptr->full_name); 
     3632        strnfmt(the_score.who, sizeof(the_score.who), "%-.15s", op_ptr->full_name); 
    36423633 
    36433634        /* Save the player info XXX XXX XXX */ 
    3644         sprintf(the_score.uid, "%7u", player_uid); 
    3645         sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f')); 
    3646         sprintf(the_score.p_r, "%2d", p_ptr->prace); 
    3647         sprintf(the_score.p_c, "%2d", p_ptr->pclass); 
     3635        strnfmt(the_score.uid, sizeof(the_score.uid), "%7u", player_uid); 
     3636        strnfmt(the_score.sex, sizeof(the_score.sex), "%c", (p_ptr->psex ? 'm' : 'f')); 
     3637        strnfmt(the_score.p_r, sizeof(the_score.p_r), "%2d", p_ptr->prace); 
     3638        strnfmt(the_score.p_c, sizeof(the_score.p_c), "%2d", p_ptr->pclass); 
    36483639 
    36493640        /* Save the level and such */ 
    3650         sprintf(the_score.cur_lev, "%3d", p_ptr->lev); 
    3651         sprintf(the_score.cur_dun, "%3d", p_ptr->depth); 
    3652         sprintf(the_score.max_lev, "%3d", p_ptr->max_lev); 
    3653         sprintf(the_score.max_dun, "%3d", p_ptr->max_depth); 
    3654  
    3655         /* Hack -- no cause of death */ 
    3656         strcpy(the_score.how, "nobody (yet!)"); 
     3641        strnfmt(the_score.cur_lev, sizeof(the_score.cur_lev), "%3d", p_ptr->lev); 
     3642        strnfmt(the_score.cur_dun, sizeof(the_score.cur_dun), "%3d", p_ptr->depth); 
     3643        strnfmt(the_score.max_lev, sizeof(the_score.max_lev), "%3d", p_ptr->max_lev); 
     3644        strnfmt(the_score.max_dun, sizeof(the_score.max_dun), "%3d", p_ptr->max_depth); 
     3645 
     3646        /* No cause of death */ 
     3647        my_strcpy(the_score.how, "nobody (yet!)", sizeof(the_score.how)); 
    36573648 
    36583649 
     
    37363727 
    37373728        /* Fake death */ 
    3738         strcpy(p_ptr->died_from, "Ripe Old Age"); 
     3729        my_strcpy(p_ptr->died_from, "Ripe Old Age", sizeof(p_ptr->died_from)); 
    37393730 
    37403731        /* Restore the experience */ 
     
    40674058 
    40684059        /* Indicate panic save */ 
    4069         strcpy(p_ptr->died_from, "(panic save)"); 
     4060        my_strcpy(p_ptr->died_from, "(panic save)", sizeof(p_ptr->died_from)); 
    40704061 
    40714062        /* Panic save, or get worried */ 
     
    41774168        { 
    41784169                /* Mark the savefile */ 
    4179                 strcpy(p_ptr->died_from, "Abortion"); 
     4170                my_strcpy(p_ptr->died_from, "Abortion", sizeof(p_ptr->died_from)); 
    41804171 
    41814172                /* HACK - Skip the tombscreen if it is already displayed */ 
     
    41944185        { 
    41954186                /* Cause of "death" */ 
    4196                 strcpy(p_ptr->died_from, "Interrupting"); 
     4187                my_strcpy(p_ptr->died_from, "Interrupting", sizeof(p_ptr->died_from)); 
    41974188 
    41984189                /* Commit suicide */ 
     
    42734264 
    42744265        /* Panic save */ 
    4275         strcpy(p_ptr->died_from, "(panic save)"); 
     4266        my_strcpy(p_ptr->died_from, "(panic save)", sizeof(p_ptr->died_from)); 
    42764267 
    42774268        /* Forbid suspend */ 
  • trunk/src/init1.c

    r110 r136  
    664664static bool add_text(u32b *offset, header *head, cptr buf) 
    665665{ 
     666        size_t len = strlen(buf); 
     667 
    666668        /* Hack -- Verify space */ 
    667         if (head->text_size + strlen(buf) + 8 > z_info->fake_text_size) 
     669        if (head->text_size + len + 8 > z_info->fake_text_size) 
    668670                return (FALSE); 
    669671 
     
    672674        { 
    673675                /* Advance and save the text index */ 
    674                 *offset = ++head->text_size;    
     676                *offset = ++head->text_size; 
    675677        } 
    676678 
    677679        /* Append chars to the text */ 
    678         strcpy(head->text_ptr + head->text_size, buf); 
     680        my_strcpy(head->text_ptr + head->text_size, buf, len + 1); 
    679681 
    680682        /* Advance the index */ 
    681         head->text_size += strlen(buf)
     683        head->text_size += len
    682684 
    683685        /* Success */ 
     
    695697{ 
    696698        u32b index; 
     699        size_t len = strlen(buf); 
    697700 
    698701        /* Hack -- Verify space */ 
    699         if (head->name_size + strlen(buf) + 8 > z_info->fake_name_size) 
     702        if (head->name_size + len + 8 > z_info->fake_name_size) 
    700703                return (0); 
    701704 
     
    704707 
    705708        /* Append chars to the names */ 
    706         strcpy(head->name_ptr + head->name_size, buf); 
     709        my_strcpy(head->name_ptr + head->name_size, buf, len + 1); 
    707710 
    708711        /* Advance the index */ 
    709         head->name_size += strlen(buf)
     712        head->name_size += len
    710713         
    711714        /* Return the name index */ 
     
    22672270 
    22682271        /* Mega-Hack -- acquire "ghost" */ 
    2269         r_ptr = &r_info[z_info->r_max-1]; 
    2270  
    2271         /* Get the next index */ 
    2272         r_ptr->name = head->name_size; 
    2273         r_ptr->text = head->text_size; 
    2274  
    2275         /* Save some space for the ghost info */ 
    2276         head->name_size += 64; 
    2277         head->text_size += 64; 
     2272        r_ptr = &r_info[z_info->r_max - 1]; 
    22782273 
    22792274        /* Hack -- Default name/text for the ghost */ 
    2280         strcpy(r_name + r_ptr->name, "Nobody, the Undefined Ghost"); 
    2281         strcpy(r_text + r_ptr->text, "It seems strangely familiar..."); 
     2275        r_ptr->name = add_name(head, "Nobody, the Undefined Ghost"); 
     2276        add_text(&r_ptr->text, head, "It seems strangely familiar..."); 
    22822277 
    22832278        /* Hack -- set the attr/char info */ 
  • trunk/src/init2.c

    r134 r136  
    7070 * try several base "path" values until a good one is found. 
    7171 */ 
    72 void init_file_paths(char *path) 
    73 
    74         char *tail; 
    75  
     72void init_file_paths(const char *path) 
     73
    7674#ifdef PRIVATE_USER_PATH 
    7775        char buf[1024]; 
     
    9694        string_free(ANGBAND_DIR_USER); 
    9795        string_free(ANGBAND_DIR_XTRA); 
    98         string_free(ANGBAND_DIR_SCRIPT); 
    99  
    100  
    101         /*** Prepare the "path" ***/ 
    102  
    103         /* Hack -- save the main directory */ 
     96 
     97 
     98        /*** Prepare the paths ***/ 
     99 
     100        /* Save the main directory */ 
    104101        ANGBAND_DIR = string_make(path); 
    105102 
    106         /* Prepare to append to the Base Path */ 
    107         tail = path + strlen(path); 
    108  
    109  
    110         /*** Build the sub-directory names ***/ 
    111  
    112         /* Build a path name */ 
    113         strcpy(tail, "edit"); 
    114         ANGBAND_DIR_EDIT = string_make(path); 
    115  
    116         /* Build a path name */ 
    117         strcpy(tail, "file"); 
    118         ANGBAND_DIR_FILE = string_make(path); 
    119  
    120         /* Build a path name */ 
    121         strcpy(tail, "help"); 
    122         ANGBAND_DIR_HELP = string_make(path); 
    123  
    124         /* Build a path name */ 
    125         strcpy(tail, "info"); 
    126         ANGBAND_DIR_INFO = string_make(path); 
    127  
    128         /* Build a path name */ 
    129         strcpy(tail, "pref"); 
    130         ANGBAND_DIR_PREF = string_make(path); 
     103        /* Build path names */ 
     104        ANGBAND_DIR_EDIT = string_make(format("%sedit", path)); 
     105        ANGBAND_DIR_FILE = string_make(format("%sfile", path)); 
     106        ANGBAND_DIR_HELP = string_make(format("%shelp", path)); 
     107        ANGBAND_DIR_INFO = string_make(format("%sinfo", path)); 
     108        ANGBAND_DIR_PREF = string_make(format("%spref", path)); 
     109        ANGBAND_DIR_XTRA = string_make(format("%sxtra", path)); 
     110 
    131111 
    132112#ifdef PRIVATE_USER_PATH 
    133113 
    134         /* Get an absolute path from the filename */ 
     114        /* Get an absolute path from the filename, */ 
    135115        path_parse(dirpath, sizeof(dirpath), PRIVATE_USER_PATH); 
     116 
    136117        /* Build the path to the user specific directory */ 
    137118        path_build(buf, sizeof(buf), dirpath, VERSION_NAME); 
    138  
    139         /* Build a relative path name */ 
    140119        ANGBAND_DIR_USER = string_make(buf); 
    141120 
    142 #else /* PRIVATE_USER_PATH */ 
    143  
    144         /* Build a path name */ 
    145         strcpy(tail, "user"); 
    146         ANGBAND_DIR_USER = string_make(path); 
    147  
    148 #endif /* PRIVATE_USER_PATH */ 
    149  
    150 #ifdef USE_PRIVATE_PATHS 
    151121 
    152122        /* Build the path to the user specific sub-directory */ 
    153123        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "scores"); 
    154  
    155         /* Build a relative path name */ 
    156124        ANGBAND_DIR_APEX = string_make(buf); 
    157125 
    158126        /* Build the path to the user specific sub-directory */ 
    159127        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "bone"); 
    160  
    161         /* Build a relative path name */ 
    162128        ANGBAND_DIR_BONE = string_make(buf); 
    163129 
    164130        /* Build the path to the user specific sub-directory */ 
    165131        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "data"); 
    166  
    167         /* Build a relative path name */ 
    168132        ANGBAND_DIR_DATA = string_make(buf); 
    169133 
    170134        /* Build the path to the user specific sub-directory */ 
    171135        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "save"); 
    172  
    173         /* Build a relative path name */ 
    174136        ANGBAND_DIR_SAVE = string_make(buf); 
    175137 
    176138#else /* USE_PRIVATE_PATHS */ 
    177139 
    178         /* Build a path name */ 
    179         strcpy(tail, "apex"); 
    180         ANGBAND_DIR_APEX = string_make(path); 
    181  
    182         /* Build a path name */ 
    183         strcpy(tail, "bone"); 
    184         ANGBAND_DIR_BONE = string_make(path); 
    185  
    186         /* Build a path name */ 
    187         strcpy(tail, "data"); 
    188         ANGBAND_DIR_DATA = string_make(path); 
    189  
    190         /* Build a path name */ 
    191         strcpy(tail, "save"); 
    192         ANGBAND_DIR_SAVE = string_make(path); 
     140        /* Build pathnames */ 
     141        ANGBAND_DIR_USER = string_make(format("%suser", path)); 
     142        ANGBAND_DIR_APEX = string_make(format("%sapex", path)); 
     143        ANGBAND_DIR_BONE = string_make(format("%sbone", path)); 
     144        ANGBAND_DIR_DATA = string_make(format("%sdata", path)); 
     145        ANGBAND_DIR_SAVE = string_make(format("%ssave", path)); 
    193146 
    194147#endif /* USE_PRIVATE_PATHS */ 
    195  
    196         /* Build a path name */ 
    197         strcpy(tail, "xtra"); 
    198         ANGBAND_DIR_XTRA = string_make(path); 
    199  
    200         /* Build a path name */ 
    201         strcpy(tail, "script"); 
    202         ANGBAND_DIR_SCRIPT = string_make(path); 
    203148} 
    204149 
     
    19671912        string_free(ANGBAND_DIR_USER); 
    19681913        string_free(ANGBAND_DIR_XTRA); 
    1969         string_free(ANGBAND_DIR_SCRIPT); 
    1970 
     1914
  • trunk/src/load.c

    r135 r136  
    23152315                { 
    23162316                        /* Reset cause of death */ 
    2317                         strcpy(p_ptr->died_from, "(alive and well)"); 
     2317                        my_strcpy(p_ptr->died_from, "(alive and well)", sizeof(p_ptr->died_from)); 
    23182318                } 
    23192319 
  • trunk/src/maid-x11.c

    r1 r136  
    104104 
    105105        /* Window specific font name */ 
    106         sprintf(buf, "ANGBAND_X11_FONT_%d", term_num); 
     106        strnfmt(buf, sizeof(buf), "ANGBAND_X11_FONT_%d", term_num); 
    107107 
    108108        /* Check environment for that font */ 
  • trunk/src/main-crb.c

    r107 r136  
    807807        td->font_wid = (info->font_wid +.999); 
    808808        td->font_hgt = info->ascent + info->descent; 
    809         strncpy(td->font_name, info->psname, sizeof(td->font_name)); 
     809        my_strcpy(td->font_name, info->psname, sizeof(td->font_name)); 
    810810 
    811811        /* Set default tile size */ 
     
    23272327                        if(fid) td->font_id = fid; 
    23282328                        /* Use the default */ 
    2329                         else strncpy(td->font_name, "Monaco", sizeof(td->font_name)); 
     2329                        else my_strcpy(td->font_name, "Monaco", sizeof(td->font_name)); 
    23302330                } 
    23312331        } 
     
    23572357        /* Default font */ 
    23582358        td->font_id = fid; 
    2359         strncpy(td->font_name, "Monaco", sizeof(td->font_name)); 
     2359        my_strcpy(td->font_name, "Monaco", sizeof(td->font_name)); 
    23602360 
    23612361        /* Default font size - was 12 */ 
  • trunk/src/main-ros.c

    r109 r136  
    877877        va_list ap; 
    878878        char buffer[260]; 
     879 
    879880        va_start(ap, fmt); 
    880         vsprintf(buffer, fmt, ap); 
     881        vstrnfmt(buffer, sizeof(buffer), fmt, ap); 
    881882        va_end(ap); 
     883 
    882884        plog(buffer); 
    883885} 
     
    960962        char buffer[2048]; 
    961963        va_start(ap, fmt); 
    962         vsprintf(buffer, fmt, ap); 
     964        vstrnfmt(buffer, sizeof(buffer), fmt, ap); 
    963965        va_end(ap); 
    964966 
     
    994996        { 
    995997                char tmp[512]; 
    996                 strcpy(tmp, scrap_path); 
     998                my_strcpy(tmp, scrap_path, sizeof(tmp)); 
    997999                tmp[strlen(tmp) - 1] = 0;       /* Remove trailing dot */ 
    9981000 
     
    12141216{ 
    12151217        char new_[260]; 
    1216         strcpy(new_, riscosify_name(new)); 
     1218        my_strcpy(new_, riscosify_name(new), sizeof(new_)); 
    12171219        return rename(riscosify_name(old), new_) ? 1 : 0; 
    12181220} 
     
    16601662        font_path = getenv(path); 
    16611663        if (!font_path || !*font_path) 
    1662                 strcpy(path, "null:$."); 
     1664                my_strcpy(path, "null:$.", sizeof(path)); 
    16631665        else 
    16641666        { 
    1665                 strcpy(path, font_path); 
     1667                my_strcpy(path, font_path, sizeof(path)); 
    16661668                for (t = path; *t > ' '; t++) 
    16671669                        ; 
     
    21542156 
    21552157        /* Preserve the old path, in case something goes wrong... */ 
    2156         strcpy(old_savefile, savefile); 
     2158        my_strcpy(old_savefile, savefile, sizeof(old_savefile)); 
    21572159 
    21582160        /* Set the new path */ 
    2159         strcpy(savefile, unixify_name(filename)); 
     2161        my_strcpy(savefile, unixify_name(filename), sizeof(savefile)); 
    21602162 
    21612163        /* Try a save (if sensible) */ 
     
    21672169                        { 
    21682170                                Msgs_Report(0, "err.save", filename); 
    2169                                 strcpy(savefile, old_savefile); 
     2171                                my_strcpy(savefile, old_savefile, sizeof(savefile)); 
    21702172                                return FALSE;           /* => failure */ 
    21712173                        } 
     
    21742176                { 
    21752177                        Msgs_Report(0, "err.nosave"); 
    2176                         strcpy(savefile, old_savefile); 
     2178                        my_strcpy(savefile, old_savefile, sizeof(savefile)); 
    21772179                        return TRUE; /* Failed really, but not unexpectedly */ 
    21782180                } 
     
    27692771        } 
    27702772 
    2771         strcpy(buffer, t); 
     2773        my_strcpy(buffer, t, sizeof(buffer)); 
    27722774 
    27732775        /* 
     
    28502852 
    28512853                /* Fudge so that the fontpath can be a path, not just a dir. */ 
    2852                 strcpy(menu_buffer, t); 
     2854                my_strcpy(menu_buffer, t, sizeof(menu_buffer)); 
    28532855                for (t = menu_buffer; *t > ' '; t++) 
    28542856                        ; 
     
    30833085        menu_item *mi = (menu_item *) (fm + 1); 
    30843086 
    3085         strcpy(buffer, prefix); 
     3087        my_strcpy(buffer, prefix, sizeof(buffer)); 
     3088 
    30863089        pl = strlen(buffer); 
    30873090        b_leaf = buffer + pl; 
     
    31013104                { 
    31023105                        /* Yes - must be a partial match (with a dot on :) */ 
    3103                         strcat(b_leaf, "."); 
     3106                        my_strcat(b_leaf, ".", sizeof(buffer) - pl); 
    31043107                        mi->menuflags.data.ticked = 
    31053108                                !strncmp(buffer, fn, pl + strlen(b_leaf)); 
     
    71587161 
    71597162        va_start(ap, fmt); 
    7160         vsprintf(buffer, fmt, ap); 
     7163        vstrnfmt(buffer, sizeof(buffer), fmt, ap); 
    71617164        Term_putstr(x, y, -1, c, buffer); 
    71627165        va_end(ap); 
     
    86318634 
    86328635        va_start(ap, fmt); 
    8633         vsprintf(buffer, fmt, ap); 
     8636        vstrnfmt(buffer, sizeof(buffer), fmt, ap); 
    86348637        va_end(ap); 
    86358638 
  • trunk/src/main-win.c

    r115 r136  
    31483148 
    31493149        /* Extract filename */ 
    3150         *savefile = '\0'; 
    3151         strncat(savefile, s, sizeof(savefile) - 1); 
     3150        my_strcpy(savefile, s, sizeof(savefile)); 
    31523151 
    31533152        /* Validate the file */ 
  • trunk/src/main-x11.c

    r82 r136  
    28112811        ch->res_name = res_name; 
    28122812 
    2813         strcpy(res_class, "Angband"); 
     2813        my_strcpy(res_class, "Angband", sizeof(res_class)); 
    28142814        ch->res_class = res_class; 
    28152815 
  • trunk/src/main-xxx.c

    r82 r136  
    722722        /* so that it points at the "lib" directory.  Every */ 
    723723        /* machine handles this in a different way... */ 
    724         strcpy(path, "XXX XXX XXX"); 
     724        my_strcpy(path, "XXX XXX XXX", sizeof(path)); 
    725725 
    726726        /* Prepare the filepaths */ 
  • trunk/src/object1.c

    r123 r136  
    19521952        byte attr; 
    19531953 
    1954         char tmp_val[80]; 
     1954        char tmp_val[10]; 
    19551955 
    19561956        char o_name[80]; 
     
    20102010                { 
    20112011                        int wgt = o_ptr->weight * o_ptr->number;