aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-07-29 23:08:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-07-29 23:08:33 -0700
commit768aeab3232cd3077ffff579ff2d59441c6968ef (patch)
treeb6e9ee045fb84e1e4f2870db1f6a0047d26ca8f1
parent2f27d6c386daff041017b7aaec51d0e50e603a8e (diff)
downloadsafepath-768aeab3232cd3077ffff579ff2d59441c6968ef.tar.gz
safepath-768aeab3232cd3077ffff579ff2d59441c6968ef.tar.bz2
safepath-768aeab3232cd3077ffff579ff2d59441c6968ef.zip
Fix link grafting bug.
Reported by Travis Ormandy in comp.unix.programmer. * safepath.c (safepath_check): In the case when we are combining a relative symlink target with remaining material from the path, there is a forgotten 1 offset which causes the slash between them to be deleted.
-rw-r--r--safepath.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/safepath.c b/safepath.c
index 06b835a..f91ff58 100644
--- a/safepath.c
+++ b/safepath.c
@@ -470,7 +470,7 @@ int safepath_check(const char *name)
memcpy(resolved, copy, pos);
strcpy(resolved + pos, link);
resolved[pos + len] = '/';
- strcpy(resolved + pos + len, copy + nxslash + 1);
+ strcpy(resolved + pos + len + 1, copy + nxslash + 1);
free(copy);
copy = resolved;
continue;