+2008-03-21 Ian Jackson <ian@davenant.greenend.org.uk>
+
+ * src/archives.c (tarobject): Make 'fd' static.
+ * lib/parse.c (parsedb): Likewise. Use ehflag_normaltidy on
+ push_cleanup and pop_cleanup. Move pop_cleanup call just before its
+ related close call.
+ * src/processarc.c (process_archive): Do not install two cleanup
+ handlers to close the fsys-tarfile pipe. Mark pipe descriptors with
+ invalid values when closed.
+
2008-03-20 Guillem Jover <guillem@debian.org>
* dpkg-deb/extract.c (safe_fflush): Change return type from int to
a non glibc claims to be glibc. Closes: #465420
* Fix crash when a .deb file becomes unreadable while dpkg is starting.
Thanks to Ian Jackson. Closes: #386210
+ * Few file descriptor cleanup and error handling fixes.
+ Thanks to Ian Jackson. Closes: #443338
[ Raphael Hertzog ]
* Add a warning displayed by dpkg-genchanges if the current version is
* If donep is not null only one package's information is expected.
*/
- int fd;
+ static int fd;
struct pkginfo newpig, *pigp;
struct pkginfoperfile *newpifp, *pifp;
struct arbitraryfield *arp, **larpp;
fd= open(filename, O_RDONLY);
if (fd == -1) ohshite(_("failed to open package info file `%.255s' for reading"),filename);
- push_cleanup(cu_parsedb,~0, NULL,0, 1,&fd);
+ push_cleanup(cu_parsedb, ~ehflag_normaltidy, NULL, 0, 1, &fd);
if (fstat(fd, &stat) == -1)
ohshite(_("can't stat package info file `%.255s'"),filename);
if (EOF_mmap(dataptr, endptr)) break;
if (c == '\n') lno++;
}
- pop_cleanup(0);
if (data != NULL) {
#ifdef HAVE_MMAP
munmap(data, stat.st_size);
#endif
}
free(value);
+ pop_cleanup(ehflag_normaltidy);
if (close(fd)) ohshite(_("failed to close after read: `%.255s'"),filename);
if (donep && !pdone) ohshit(_("no package information in `%.255s'"),filename);
int tarobject(struct TarInfo *ti) {
static struct varbuf conffderefn, hardlinkfn, symlinkfn;
+ static int fd;
const char *usename;
struct conffile *conff;
struct tarcontext *tc= (struct tarcontext*)ti->UserData;
- int statr, fd, i, existingdirectory, keepexisting;
+ int statr, i, existingdirectory, keepexisting;
ssize_t r;
struct stat stab, stabtmp;
char databuf[TARBLKSZ];
ohshite(_("unable to exec dpkg-deb to get filesystem archive"));
}
close(p1[1]);
+ p1[1] = -1;
newfileslist = NULL;
tc.newfilesp = &newfileslist;
push_cleanup(cu_fileslist, ~0, NULL, 0, 0);
tc.pkg= pkg;
tc.backendpipe= p1[0];
- push_cleanup(cu_closefd, ~ehflag_bombout, NULL, 0, 1, &tc.backendpipe);
r= TarExtractor((void*)&tc, &tf);
if (r) {
ohshit(_("corrupted filesystem tarfile - corrupted package archive"));
}
}
- fd_null_copy(tc.backendpipe,-1,_("dpkg-deb: zap possible trailing zeros"));
- close(tc.backendpipe);
+ fd_null_copy(p1[0], -1, _("dpkg-deb: zap possible trailing zeros"));
+ close(p1[0]);
+ p1[0] = -1;
waitsubproc(c1,BACKEND " --fsys-tarfile",PROCPIPE);
if (oldversionstatus == stat_halfinstalled || oldversionstatus == stat_unpacked) {