55 lines
2.1 KiB
Diff
55 lines
2.1 KiB
Diff
From faaf3bbfc261f49eda996801b50996fb1066092f Mon Sep 17 00:00:00 2001
|
|
From: Mark Wielaard <mark@klomp.org>
|
|
Date: Wed, 28 Jun 2017 20:25:39 +0200
|
|
Subject: [PATCH] debugedit: skip_dir_prefix should check for dir separator.
|
|
|
|
To count as a real directory prefix the string matched should either
|
|
be equal to the given prefix or start with the prefix plus '/'.
|
|
|
|
skip_dir_prefix is always used with base_dir or dest_dir which don't
|
|
end with a slash themselves.
|
|
|
|
This really only is an issue if a package would put a directory named
|
|
similar to the package source dir (which cargo on fedora does, by adding
|
|
a directory named cargo-vendor in the builddir itself).
|
|
|
|
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
|
(cherry picked from commit 2ea5619e375f0717b755c8aa4a38254ea622b833)
|
|
---
|
|
tools/debugedit.c | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/tools/debugedit.c b/tools/debugedit.c
|
|
index bf115136c..682189929 100644
|
|
--- a/tools/debugedit.c
|
|
+++ b/tools/debugedit.c
|
|
@@ -662,7 +662,8 @@ canonicalize_path (const char *s, char *d)
|
|
/* Returns the rest of PATH if it starts with DIR_PREFIX, skipping any
|
|
/ path separators, or NULL if PATH doesn't start with
|
|
DIR_PREFIX. Might return the empty string if PATH equals DIR_PREFIX
|
|
- (modulo trailing slashes). Never returns path starting with '/'. */
|
|
+ (modulo trailing slashes). Never returns path starting with '/'.
|
|
+ Note that DIR_PREFIX itself should NOT end with a '/'. */
|
|
static const char *
|
|
skip_dir_prefix (const char *path, const char *dir_prefix)
|
|
{
|
|
@@ -670,12 +671,17 @@ skip_dir_prefix (const char *path, const char *dir_prefix)
|
|
if (strncmp (path, dir_prefix, prefix_len) == 0)
|
|
{
|
|
path += prefix_len;
|
|
+ /* Unless path == dir_prefix there should be at least one '/'
|
|
+ in the path (which we will skip). Otherwise the path has
|
|
+ a different (longer) directory prefix. */
|
|
+ if (*path != '\0' && !IS_DIR_SEPARATOR (*path))
|
|
+ return NULL;
|
|
while (IS_DIR_SEPARATOR (path[0]))
|
|
path++;
|
|
return path;
|
|
}
|
|
|
|
- return 0;
|
|
+ return NULL;
|
|
}
|
|
|
|
/* Most strings will be in the existing debug string table. But to
|