diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-20 03:10:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-20 03:10:54 +0400 |
commit | 5cf593a778e3dca51a5ebd6b4c23ce6c7b0a7ac6 (patch) | |
tree | d5d8889ff9dcffa4c15b7160a8850d3f16b6562e /source/blender/blenlib | |
parent | 364fcde86d3cdcb09d075a0445fc2e1eb64170d5 (diff) |
strcpy() --> BLI_strncpy(), where source strings are not fixed and target size is known.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 8 | ||||
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 12 |
3 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 9ccd7fbe121..e848ad8d0d3 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -227,7 +227,7 @@ int BLI_move(const char *file, const char *to) { // it has to be 'mv filename filename' and not // 'mv filename destdir' - strcpy(str, to); + BLI_strncpy(str, to, sizeof(str)); // points 'to' to a directory ? if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { @@ -252,7 +252,7 @@ int BLI_copy_fileops(const char *file, const char *to) { // it has to be 'cp filename filename' and not // 'cp filename destdir' - strcpy(str, to); + BLI_strncpy(str, to, sizeof(str)); // points 'to' to a directory ? if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { @@ -286,7 +286,7 @@ void BLI_recurdir_fileops(const char *dirname) { // blah1/blah2/ (with slash) after creating // blah1/blah2 (without slash) - strcpy(tmp, dirname); + BLI_strncpy(tmp, dirname, sizeof(tmp)); lslash= BLI_last_slash(tmp); if (lslash == tmp + strlen(tmp) - 1) { @@ -371,7 +371,7 @@ void BLI_recurdir_fileops(const char *dirname) { if (BLI_exists(dirname)) return; - strcpy(tmp, dirname); + BLI_strncpy(tmp, dirname, sizeof(tmp)); lslash= BLI_last_slash(tmp); if (lslash) { diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 0fe028eb3c0..7e5d03423e5 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -364,7 +364,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf) // get the name fontname = FT_Get_Postscript_Name(face); - strcpy(vfd->name, (fontname == NULL) ? "" : fontname); + BLI_strncpy(vfd->name, (fontname == NULL) ? "" : fontname, sizeof(vfd->name)); // Extract the first 256 character from TTF lcode= charcode= FT_Get_First_Char(face, &glyph_index); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index e336b914ffa..7638e95b4ec 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -304,15 +304,15 @@ void BLI_adddirstrings(void) for(num=0, file= files; num<actnum; num++, file++){ #ifdef WIN32 mode = 0; - strcpy(file->mode1, types[0]); - strcpy(file->mode2, types[0]); - strcpy(file->mode3, types[0]); + BLI_strncpy(file->mode1, types[0], sizeof(file->mode1)); + BLI_strncpy(file->mode2, types[0], sizeof(file->mode2)); + BLI_strncpy(file->mode3, types[0], sizeof(file->mode3)); #else mode = file->s.st_mode; - strcpy(file->mode1, types[(mode & 0700) >> 6]); - strcpy(file->mode2, types[(mode & 0070) >> 3]); - strcpy(file->mode3, types[(mode & 0007)]); + BLI_strncpy(file->mode1, types[(mode & 0700) >> 6], sizeof(file->mode1)); + BLI_strncpy(file->mode2, types[(mode & 0070) >> 3], sizeof(file->mode2)); + BLI_strncpy(file->mode3, types[(mode & 0007)], sizeof(file->mode3)); if (((mode & S_ISGID) == S_ISGID) && (file->mode2[2]=='-'))file->mode2[2]='l'; |