mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-09-21 05:26:20 +02:00
Stop using MAX_PATH, it might not be defined
This broke compilation on Hurd
This commit is contained in:
parent
0f7e96038d
commit
d916fc38b6
4
changes/bug5355
Normal file
4
changes/bug5355
Normal file
@ -0,0 +1,4 @@
|
||||
o Major bugfixes:
|
||||
- Fix a compilation issue on GNU Hurd, which doesn't have PATH_MAX. Fixes
|
||||
bug 5355; bugfix on 0.2.3.11-alpha.
|
||||
|
@ -1645,7 +1645,10 @@ make_path_absolute(char *fname)
|
||||
|
||||
return absfname;
|
||||
#else
|
||||
char path[PATH_MAX+1];
|
||||
/* We use this as a starting path length. Not too large seems sane. */
|
||||
#define START_PATH_LENGTH 100
|
||||
size_t path_length = START_PATH_LENGTH;
|
||||
char *path = tor_malloc(path_length);
|
||||
char *absfname = NULL;
|
||||
|
||||
tor_assert(fname);
|
||||
@ -1653,14 +1656,24 @@ make_path_absolute(char *fname)
|
||||
if (fname[0] == '/') {
|
||||
absfname = tor_strdup(fname);
|
||||
} else {
|
||||
if (getcwd(path, PATH_MAX) != NULL) {
|
||||
tor_asprintf(&absfname, "%s/%s", path, fname);
|
||||
int save_errno = errno;
|
||||
errno = 0;
|
||||
while (getcwd(path, path_length) == NULL) {
|
||||
if (errno == ERANGE) {
|
||||
path_length*=2;
|
||||
path = tor_realloc(path, path_length);
|
||||
} else {
|
||||
/* If getcwd failed, the best we can do here is keep using the
|
||||
* relative path. (Perhaps / isn't readable by this UID/GID.) */
|
||||
/* If getcwd failed with an error other than ERANGE, the best we can
|
||||
* do here is keep using the relative path. (Perhaps / isn't readable
|
||||
* by this UID/GID.) */
|
||||
absfname = tor_strdup(fname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
errno = save_errno;
|
||||
tor_asprintf(&absfname, "%s/%s", path, fname);
|
||||
tor_free(path);
|
||||
}
|
||||
|
||||
return absfname;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user