teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame debugedit-prefix.patch

Mark Wielaard 6e205b
diff --git a/tools/debugedit.c b/tools/debugedit.c
Mark Wielaard 6e205b
index abd2ca4..a271b91 100644
Mark Wielaard 6e205b
--- a/tools/debugedit.c
Mark Wielaard 6e205b
+++ b/tools/debugedit.c
Mark Wielaard 6e205b
@@ -662,7 +662,8 @@ canonicalize_path (const char *s, char *d)
Mark Wielaard 6e205b
 /* Returns the rest of PATH if it starts with DIR_PREFIX, skipping any
Mark Wielaard 6e205b
    / path separators, or NULL if PATH doesn't start with
Mark Wielaard 6e205b
    DIR_PREFIX. Might return the empty string if PATH equals DIR_PREFIX
Mark Wielaard 6e205b
-   (modulo trailing slashes). Never returns path starting with '/'. */
Mark Wielaard 6e205b
+   (modulo trailing slashes). Never returns path starting with '/'.
Mark Wielaard 6e205b
+   Note that DIR_PREFIX itself should NOT end with a '/'.  */
Mark Wielaard 6e205b
 static const char *
Mark Wielaard 6e205b
 skip_dir_prefix (const char *path, const char *dir_prefix)
Mark Wielaard 6e205b
 {
Mark Wielaard 6e205b
@@ -670,12 +671,17 @@ skip_dir_prefix (const char *path, const char *dir_prefix)
Mark Wielaard 6e205b
   if (strncmp (path, dir_prefix, prefix_len) == 0)
Mark Wielaard 6e205b
     {
Mark Wielaard 6e205b
       path += prefix_len;
Mark Wielaard 6e205b
+      /* Unless path == dir_prefix there should be at least one '/'
Mark Wielaard 6e205b
+	 in the path (which we will skip).  Otherwise the path has
Mark Wielaard 6e205b
+	 a different (longer) directory prefix.  */
Mark Wielaard 6e205b
+      if (*path != '\0' && !IS_DIR_SEPARATOR (*path))
Mark Wielaard 6e205b
+	return NULL;
Mark Wielaard 6e205b
       while (IS_DIR_SEPARATOR (path[0]))
Mark Wielaard 6e205b
 	path++;
Mark Wielaard 6e205b
       return path;
Mark Wielaard 6e205b
     }
Mark Wielaard 6e205b
 
Mark Wielaard 6e205b
-  return 0;
Mark Wielaard 6e205b
+  return NULL;
Mark Wielaard 6e205b
 }
Mark Wielaard 6e205b
 
Mark Wielaard 6e205b
 /* Most strings will be in the existing debug string table. But to