]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-install): convert_abs_rel: return valid path on error
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Thu, 28 Apr 2022 16:46:28 +0000 (18:46 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Fri, 24 Jun 2022 20:27:08 +0000 (20:27 +0000)
convert_abs_rel() gets
  from  =/var/tmp/dracut.8dxnpY/initramfs/lib/x86_64-linux-gnu/libuuid.so.1.3.0
  target=/var/tmp/dracut.8dxnpY/initramfs/lib/x86_64-linux-gnu/libuuid.so
returning from is invalid; skip over the destdir:
  /lib/x86_64-linux-gnu/libuuid.so.1.3.0

src/install/dracut-install.c

index 21178e57f1e5670f4f5942d14886f25f47ecd319..31ac4f0f4abbc179f2d6c9764f0f465047a4b562 100644 (file)
@@ -173,12 +173,12 @@ static char *convert_abs_rel(const char *from, const char *target)
         dirlen = dir_len(target);
         target_dir_p = strndup(target, dirlen);
         if (!target_dir_p)
-                return strdup(from);
+                return strdup(from + strlen(destrootdir));
 
         realpath_p = realpath(target_dir_p, NULL);
         if (realpath_p == NULL) {
                 log_warning("convert_abs_rel(): target '%s' directory has no realpath.", target);
-                return strdup(from);
+                return strdup(from + strlen(destrootdir));
         }
 
         /* dir_len() skips double /'s e.g. //lib64, so we can't skip just one