+2008-07-01 Guillem Jover <guillem@debian.org>
+
+ * src/processarc.c (process_archive): Do not allocate a struct stat
+ when lstat fails, instead assign a pointer to a static empty stat
+ variable that will mark it as such.
+
2008-06-30 Guillem Jover <guillem@debian.org>
* lib/showpkg.c (parsefield): Remove unneeded 'const char *' cast.
* Support diverting files when origin and destination are on different file
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.
[ Raphael Hertzog ]
* Enhance dpkg-shlibdeps's error message when a library can't be found to
* since ones that stayed the same don't really apply here.
*/
struct fileinlist *sameas = NULL;
+ static struct stat empty_stat;
+
/* If we can't stat the old or new file, or it's a directory,
* we leave it up to the normal code
*/
for (cfile= newfileslist; cfile; cfile= cfile->next) {
if (!cfile->namenode->filestat) {
- cfile->namenode->filestat= nfmalloc(sizeof(struct stat));
- if (lstat(cfile->namenode->name, cfile->namenode->filestat)) {
+ struct stat tmp_stat;
+
+ if (lstat(cfile->namenode->name, &tmp_stat) == 0) {
+ cfile->namenode->filestat = nfmalloc(sizeof(struct stat));
+ memcpy(cfile->namenode->filestat, &tmp_stat, sizeof(struct stat));
+ } else {
if (!(errno == ENOENT || errno == ELOOP || errno == ENOTDIR))
ohshite(_("unable to stat other new file `%.250s'"),
cfile->namenode->name);
- memset(cfile->namenode->filestat, 0,
- sizeof(*cfile->namenode->filestat));
+ cfile->namenode->filestat = &empty_stat;
continue;
}
}
- if (!cfile->namenode->filestat->st_mode) continue;
+ if (cfile->namenode->filestat == &empty_stat)
+ continue;
if (oldfs.st_dev == cfile->namenode->filestat->st_dev &&
oldfs.st_ino == cfile->namenode->filestat->st_ino) {
if (sameas)