diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-02-13 06:21:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-02-13 06:21:27 +0300 |
commit | 867fc4b463ef39ea16103f18f332c3d259624d29 (patch) | |
tree | 7d20c416241afb7b878b767a9955e284d3cddbe2 /source/blender/windowmanager | |
parent | 9e03a0d4762b4734fe7ccb20e03b4a3c8f939620 (diff) |
enforce string limits (reported by pedantic checking tools & some developers).
mostly replace strcpy with BLI_strncpy and multiple strcat's with a BLI_snprintf().
also fix possible crash if CWD isnt available.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 8e5658865d2..31873160944 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -259,7 +259,7 @@ static void wm_init_userdef(bContext *C) /* set the python auto-execute setting from user prefs */ /* disabled by default, unless explicitly enabled in the command line */ if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC; - if(U.tempdir[0]) BLI_where_is_temp(btempdir, 1); + if(U.tempdir[0]) BLI_where_is_temp(btempdir, FILE_MAX, 1); } void WM_read_file(bContext *C, const char *name, ReportList *reports) @@ -469,10 +469,7 @@ void read_history(void) if (line[0] && BLI_exists(line)) { recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile"); BLI_addtail(&(G.recent_files), recent); - recent->filepath = (char*)MEM_mallocN(sizeof(char)*(strlen(line)+1), "name of file"); - recent->filepath[0] = '\0'; - - strcpy(recent->filepath, line); + recent->filepath = BLI_strdup(line); num++; } } @@ -505,7 +502,7 @@ static void write_history(void) recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile"); recent->filepath = (char*)MEM_mallocN(sizeof(char)*(strlen(G.main->name)+1), "name of file"); recent->filepath[0] = '\0'; - strcpy(recent->filepath, G.main->name); + BLI_strncpy(recent->filepath, G.main->name, sizeof(recent->filepath)); BLI_addhead(&(G.recent_files), recent); /* write current file to recent-files.txt */ fprintf(fp, "%s\n", recent->filepath); @@ -671,7 +668,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) { if(!copy) { G.relbase_valid = 1; - strcpy(G.main->name, di); /* is guaranteed current file */ + BLI_strncpy(G.main->name, di, sizeof(G.main->name)); /* is guaranteed current file */ G.save_over = 1; /* disable untitled.blend convention */ } |