mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-22 06:21:55 +01:00
Merge branch 'bug1522'
This commit is contained in:
commit
2aa6fc5ae8
2 changed files with 9 additions and 10 deletions
3
changes/bug1522
Normal file
3
changes/bug1522
Normal file
|
@ -0,0 +1,3 @@
|
|||
o Minor bugfixes
|
||||
- Treat an unset $HOME like an empty $HOME. Fixes bug 1522; bugfix on
|
||||
tor-0.0.8pre1.
|
|
@ -2317,18 +2317,18 @@ expand_filename(const char *filename)
|
|||
return tor_strdup(filename);
|
||||
#else
|
||||
if (*filename == '~') {
|
||||
size_t len;
|
||||
char *home, *result;
|
||||
char *home, *result=NULL;
|
||||
const char *rest;
|
||||
|
||||
if (filename[1] == '/' || filename[1] == '\0') {
|
||||
home = getenv("HOME");
|
||||
if (!home) {
|
||||
log_warn(LD_CONFIG, "Couldn't find $HOME environment variable while "
|
||||
"expanding \"%s\"", filename);
|
||||
return NULL;
|
||||
"expanding \"%s\"; defaulting to \"\".", filename);
|
||||
home = tor_strdup("");
|
||||
} else {
|
||||
home = tor_strdup(home);
|
||||
}
|
||||
home = tor_strdup(home);
|
||||
rest = strlen(filename)>=2?(filename+2):"";
|
||||
} else {
|
||||
#ifdef HAVE_PWD_H
|
||||
|
@ -2355,11 +2355,7 @@ expand_filename(const char *filename)
|
|||
if (strlen(home)>1 && !strcmpend(home,PATH_SEPARATOR)) {
|
||||
home[strlen(home)-1] = '\0';
|
||||
}
|
||||
/* Plus one for /, plus one for NUL.
|
||||
* 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);
|
||||
tor_asprintf(&result,"%s"PATH_SEPARATOR"%s",home,rest);
|
||||
tor_free(home);
|
||||
return result;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue