Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-13 06:21:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-13 06:21:27 +0300
commit867fc4b463ef39ea16103f18f332c3d259624d29 (patch)
tree7d20c416241afb7b878b767a9955e284d3cddbe2 /source/blender/editors/space_file/file_ops.c
parent9e03a0d4762b4734fe7ccb20e03b4a3c8f939620 (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/editors/space_file/file_ops.c')
-rw-r--r--source/blender/editors/space_file/file_ops.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 55dc19d9bb9..fea50f1f2aa 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -541,7 +541,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot)
void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
{
- BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
+ BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */
if(RNA_struct_find_property(op->ptr, "relative_path")) {
if(RNA_boolean_get(op->ptr, "relative_path")) {
BLI_path_rel(filepath, G.main->name);
@@ -639,7 +639,7 @@ int file_draw_check_exists(SpaceFile *sfile)
if(RNA_struct_find_property(sfile->op->ptr, "check_existing")) {
if(RNA_boolean_get(sfile->op->ptr, "check_existing")) {
char filepath[FILE_MAX];
- BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
+ BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file);
if(BLI_exists(filepath) && !BLI_is_dir(filepath)) {
return TRUE;
}
@@ -929,13 +929,13 @@ static int new_folder_path(const char* parent, char *folder, char *name)
int len = 0;
BLI_strncpy(name, "New Folder", FILE_MAXFILE);
- BLI_join_dirfile(folder, parent, name);
+ BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */
/* check whether folder with the name already exists, in this case
add number to the name. Check length of generated name to avoid
crazy case of huge number of folders each named 'New Folder (x)' */
while (BLI_exists(folder) && (len<FILE_MAXFILE)) {
len = BLI_snprintf(name, FILE_MAXFILE, "New Folder(%d)", i);
- BLI_join_dirfile(folder, parent, name);
+ BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */
i++;
}
@@ -1017,8 +1017,8 @@ static void file_expand_directory(bContext *C)
if(sfile->params) {
if ( sfile->params->dir[0] == '~' ) {
char tmpstr[sizeof(sfile->params->dir)-1];
- strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr));
- BLI_join_dirfile(sfile->params->dir, BLI_getDefaultDocumentFolder(), tmpstr);
+ BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr));
+ BLI_join_dirfile(sfile->params->dir, sizeof(sfile->params->dir), BLI_getDefaultDocumentFolder(), tmpstr);
}
#ifdef WIN32