diff options
-rw-r--r-- | ChangeLog.txt | 3 | ||||
-rw-r--r-- | pseudo_util.c | 10 |
2 files changed, 10 insertions, 3 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 7174ab1..702ae9e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,6 @@ +2012-06-27: + * (seebs) Fix chroot coredump with long root path. + 2012-04-30: * (seebs) Update README about new upstream. diff --git a/pseudo_util.c b/pseudo_util.c index fd3236d..95844fa 100644 --- a/pseudo_util.c +++ b/pseudo_util.c @@ -597,9 +597,13 @@ pseudo_fix_path(const char *base, const char *path, size_t rootlen, size_t basel } pathlen = strlen(path); newpathlen = pathlen; - if (baselen && path[0] != '/') { + /* If the path starts with /, we don't care about base, UNLESS + * rootlen is non-zero, in which case we're doing a chroot thing + * and will actually need to append some components. + */ + if (baselen && (path[0] != '/' || rootlen)) { newpathlen += baselen + 2; - } + } /* allow a bit of slush. overallocating a bit won't * hurt. rounding to 256's in the hopes that it makes life * easier for the library. @@ -611,7 +615,7 @@ pseudo_fix_path(const char *base, const char *path, size_t rootlen, size_t basel return 0; } current = newpath; - if (baselen) { + if (baselen && (path[0] != '/' || rootlen)) { memcpy(current, base, baselen); current += baselen; } |