[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#30397: "struct diversion"s not properly initialized



Package: dpkg
Version: 1.4.0.23.2
Maintainer: Klee Dienes and Ian Jackson <dpkg-maint@chiark.greenend.org.uk>

As far as I can see, this also applies to the latest "slink" version
of "dpkg", 1.4.0.31.

There's a bug in "dpkg/filesdb.c" in function "ensure_diversions".  It
fails to initialize "oialtname->useinstead" and	"oicontest->camefrom"
to zero.

I noticed it when driving "dpkg" with "apt-get dselect-upgrade" as
part of a complete install of "hamm": when "dnsutils" was installing
file "/usr/bin/dig", a bogus nonzero "->divert->useinstead" pointer on
that namenode triggered an error:

	trying to overwrite /usr/bin/dig which is the diverted version
	of `<...garbage...>' (package: dnsutils)

The enclosed patch should fix the problem, though I haven't been able
to test it because the uninitialized pointers usually happen to be
NULL anyway during normal "dpkg" usage.

Kevin Buhr <buhr@stat.wisc.edu>

			*	*	*

--- dpkg/filesdb.c      1998/12/06 00:08:38     1.1
+++ dpkg/filesdb.c      1998/12/06 00:09:34
@@ -353,6 +353,7 @@
     if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [i]"));
     linebuf[l]= 0;
     oialtname->camefrom= findnamenode(linebuf);
+    oialtname->useinstead = 0;

     if (!fgets(linebuf,sizeof(linebuf),file))
       if (ferror(file)) ohshite(_("read error in diversions [ii]"));
@@ -362,6 +363,7 @@
     if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [ii]"));
     linebuf[l]= 0;
     oicontest->useinstead= findnamenode(linebuf);
+    oicontest->camefrom = 0;

     if (!fgets(linebuf,sizeof(linebuf),file))
       if (ferror(file)) ohshite(_("read error in diversions [iii]"));


Reply to: