summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-08-31 12:51:52 +0000
committerNick Mathewson <nickm@torproject.org>2007-08-31 12:51:52 +0000
commitc341bc090e3419267f1445d4f945a3eebf687c40 (patch)
tree99307382339708292489ab8a7b275d5824300400 /src/common
parent04fcaf5f06fc1f689fde3d2d5cf970694e28a44f (diff)
downloadtor-c341bc090e3419267f1445d4f945a3eebf687c40.tar.gz
tor-c341bc090e3419267f1445d4f945a3eebf687c40.zip
r14869@catbus: nickm | 2007-08-31 08:49:26 -0400
Fix a segfault in expand_filename("~"). Found by lindi. svn:r11332
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 29513db962..d8e89395ad 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1839,7 +1839,7 @@ expand_filename(const char *filename)
return NULL;
}
home = tor_strdup(home);
- rest = strlen(filename)>=2?(filename+2):NULL;
+ rest = strlen(filename)>=2?(filename+2):"";
} else {
#ifdef HAVE_PWD_H
char *username, *slash;
@@ -1854,7 +1854,7 @@ expand_filename(const char *filename)
return NULL;
}
tor_free(username);
- rest = slash ? (slash+1) : NULL;
+ rest = slash ? (slash+1) : "";
#else
log_warn(LD_CONFIG, "Couldn't expend homedir on system without pwd.h");
return tor_strdup(filename);
@@ -1869,7 +1869,7 @@ expand_filename(const char *filename)
* Round up to 16 in case we can't do math. */
len = strlen(home)+strlen(rest)+16;
result = tor_malloc(len);
- tor_snprintf(result,len,"%s"PATH_SEPARATOR"%s",home,rest?rest:"");
+ tor_snprintf(result,len,"%s"PATH_SEPARATOR"%s",home,rest);
tor_free(home);
return result;
} else {