Parcourir la source

dpkg: Properly lstat the correct file when using --root on upgrades

Closes: #281057
Egmont Koblinger il y a 18 ans
Parent
commit
4bd246cf44
3 fichiers modifiés avec 17 ajouts et 1 suppressions
  1. 5 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 10 1
      src/processarc.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-07-01  Egmont Koblinger  <egmont@uhulinux.hu>
+
+	* src/processarc.c (process_archive): Properly lstat the correct
+	file on upgrade when using --root.
+
 2008-07-01  Guillem Jover  <guillem@debian.org>
 
 	* src/processarc.c (process_archive): Do not allocate a struct stat

+ 2 - 0
debian/changelog

@@ -23,6 +23,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     systems. Based on a patch by Juergen Kreileder. Closes: #102144, #149961
   * Do not silently enable --rename on dpkg-divert --remove. Closes: #160848
   * Do not allocate memory when lstat fails during package upgrade.
+  * Properly lstat the correct file when using --root on package upgrade.
+    Thanks to Egmont Koblinger. Closes: #281057
 
   [ Raphael Hertzog ]
   * Enhance dpkg-shlibdeps's error message when a library can't be found to

+ 10 - 1
src/processarc.c

@@ -681,6 +681,7 @@ void process_archive(const char *filename) {
        */
       struct fileinlist *sameas = NULL;
       static struct stat empty_stat;
+      struct varbuf cfilename = VARBUF_INIT;
 
       /* If we can't stat the old or new file, or it's a directory,
        * we leave it up to the normal code
@@ -692,7 +693,13 @@ void process_archive(const char *filename) {
 	if (!cfile->namenode->filestat) {
 	  struct stat tmp_stat;
 
-	  if (lstat(cfile->namenode->name, &tmp_stat) == 0) {
+	  varbufreset(&cfilename);
+	  varbufaddstr(&cfilename, instdir);
+	  varbufaddc(&cfilename, '/');
+	  varbufaddstr(&cfilename, cfile->namenode->name);
+	  varbufaddc(&cfilename, '\0');
+
+	  if (lstat(cfilename.buf, &tmp_stat) == 0) {
 	    cfile->namenode->filestat = nfmalloc(sizeof(struct stat));
 	    memcpy(cfile->namenode->filestat, &tmp_stat, sizeof(struct stat));
 	  } else {
@@ -718,6 +725,8 @@ void process_archive(const char *filename) {
 	}
       }
 
+      varbuffree(&cfilename);
+
       if ((namenode->flags & fnnf_old_conff)) {
 	if (sameas) {
 	  if (sameas->namenode->flags & fnnf_new_conff) {