From: Egmont Koblinger Date: Tue, 1 Jul 2008 06:22:14 +0000 (+0300) Subject: dpkg: Properly lstat the correct file when using --root on upgrades X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bd246cf4457a655c893a2aa226ae85ad86f54dd;p=dpkg dpkg: Properly lstat the correct file when using --root on upgrades Closes: #281057 --- diff --git a/ChangeLog b/ChangeLog index be02b230..99f2f217 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-01 Egmont Koblinger + + * src/processarc.c (process_archive): Properly lstat the correct + file on upgrade when using --root. + 2008-07-01 Guillem Jover * src/processarc.c (process_archive): Do not allocate a struct stat diff --git a/debian/changelog b/debian/changelog index bfbd6a02..d648b38e 100644 --- a/debian/changelog +++ b/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 diff --git a/src/processarc.c b/src/processarc.c index 75535d02..a3b455d4 100644 --- a/src/processarc.c +++ b/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) {