summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPaul Nasrat <pnasrat@redhat.com>2007-03-15 15:59:55 +0000
committerPaul Nasrat <pnasrat@redhat.com>2007-03-15 15:59:55 +0000
commita63c710e70d0aeb30b710d79102db543cf6e87ac (patch)
treef6d59c86b716c7ff1634b5984b87b64a0dbe97d7 /tools
parent116899502943d6a1fddaf0b832838245c8e33c1e (diff)
downloadrpm-a63c710e70d0aeb30b710d79102db543cf6e87ac.tar.gz
rpm-a63c710e70d0aeb30b710d79102db543cf6e87ac.tar.bz2
rpm-a63c710e70d0aeb30b710d79102db543cf6e87ac.zip
Fix for debugedit with ../../ in paths
Diffstat (limited to 'tools')
-rw-r--r--tools/debugedit.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 3da2ea29f..23f4227ac 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -372,38 +372,43 @@ canonicalize_path (const char *s, char *d)
if (s[0] == '.' && (s[1] == 0 || IS_DIR_SEPARATOR (s[1])))
{
s ++;
- if (*s)
- s++;
- else if (d > droot)
+ if (!*s && d > droot)
d--;
}
else if (s[0] == '.' && s[1] == '.'
&& (s[2] == 0 || IS_DIR_SEPARATOR (s[2])))
{
- char *pre = d-1; /* includes slash */
+ char *pre = d - 1; /* includes slash */
while (droot < pre && IS_DIR_SEPARATOR (*pre))
pre--;
if (droot <= pre && ! IS_DIR_SEPARATOR (*pre))
{
- d = pre;
- while (droot < d && ! IS_DIR_SEPARATOR (*d))
- d--;
- /* d now points to the slash */
- if (droot < d)
- d++;
- s += 2;
- if (*s)
- s++;
- else if (d > droot)
- d--;
+ while (droot < pre && ! IS_DIR_SEPARATOR (*pre))
+ pre--;
+ /* pre now points to the slash */
+ if (droot < pre)
+ pre++;
+ if (pre + 3 == d && pre[0] == '.' && pre[1] == '.')
+ {
+ *d++ = *s++;
+ *d++ = *s++;
+ }
+ else
+ {
+ d = pre;
+ s += 2;
+ if (*s)
+ while (IS_DIR_SEPARATOR (*s))
+ s++;
+ else if (d > droot)
+ d--;
+ }
}
else
{
*d++ = *s++;
*d++ = *s++;
- if (*s)
- *d++ = *s++;
}
}