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-10-11 09:21:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-11 09:21:24 +0400
commit85a2280c861122da70a26da0c664bc1c4615efcd (patch)
treebe406c30a030eaba53693e957015c2035ee695d0 /source/blender
parent45ad9faf342f0ae7b46959932fb49fd50e5e2ea5 (diff)
fix for crash in BLI_join_dirfile() when the dir is longer then the target string.
starting blender in a dir longer then 240 chars would crash.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/intern/path_util.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 8adede3337c..b206e275d9a 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1433,16 +1433,16 @@ void BLI_split_dirfile(const char *string, char *dir, char *file)
void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file)
{
int sl_dir;
-
+
if(string != dir) /* compare pointers */
- BLI_strncpy(string, dir, maxlen);
+ BLI_strncpy(string, dir, maxlen -(file ? 1 : 0));
if (!file)
return;
-
+
sl_dir= BLI_add_slash(string);
- if (sl_dir <FILE_MAX) {
+ if (sl_dir < maxlen) {
BLI_strncpy(string + sl_dir, file, maxlen - sl_dir);
}
}
@@ -1584,19 +1584,11 @@ char *BLI_last_slash(const char *string)
int BLI_add_slash(char *string)
{
int len = strlen(string);
-#ifdef WIN32
- if (len==0 || string[len-1]!='\\') {
- string[len] = '\\';
+ if (len==0 || string[len-1] != SEP) {
+ string[len] = SEP;
string[len+1] = '\0';
return len+1;
}
-#else
- if (len==0 || string[len-1]!='/') {
- string[len] = '/';
- string[len+1] = '\0';
- return len+1;
- }
-#endif
return len;
}
@@ -1605,11 +1597,7 @@ void BLI_del_slash(char *string)
{
int len = strlen(string);
while (len) {
-#ifdef WIN32
- if (string[len-1]=='\\') {
-#else
- if (string[len-1]=='/') {
-#endif
+ if (string[len-1] == SEP) {
string[len-1] = '\0';
len--;
} else {