summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-09-24 15:53:51 +0000
committerNick Mathewson <nickm@torproject.org>2007-09-24 15:53:51 +0000
commit2cd6a240bd7cfee15014aa62dd3a8e17ab00cd6e (patch)
tree169459980ce9300b7e56e2b5fdece733aef5d853 /src/common
parent311590550652042027daf0d954b93fed3f54b35e (diff)
downloadtor-2cd6a240bd7cfee15014aa62dd3a8e17ab00cd6e.tar.gz
tor-2cd6a240bd7cfee15014aa62dd3a8e17ab00cd6e.zip
r15320@catbus: nickm | 2007-09-24 11:49:09 -0400
Backport r11332: fix a user-triggerable segfault in expand_filename("~"). svn:r11608
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 3ab72a5745..04b59782eb 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1555,7 +1555,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;
@@ -1570,7 +1570,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);
@@ -1585,7 +1585,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/%s",home,rest?rest:"");
+ tor_snprintf(result,len,"%s/%s",home,rest);
tor_free(home);
return result;
} else {