[BusyBox] [PATCH] dpkg replace pkg SEGV fix

Stefan Soucek ssoucek at coactive.com
Fri Oct 5 14:44:34 UTC 2001


Hi,

Thanks for submitting the patches. Unfortunately, when testing them out I
get SEGVs. I've diffed my working version and there are some minor
differences. I have attached the patch to the current CVS version (1.48).

Here are the details:

Hunk #1: unpack_package(): The status_package_num is assigned a status
hash value. This should be a hash into the package hashtable instead.

Hunk #2: unpack_package(): When replacing a package remove_package() is
called. This effectively removes the files. Looking at the Debian dpkg man
page it is not supposed to do that. It should leave the files there (and
in fact back them up while overwriting; but that might be way too complex
for this tiny implementation). So I guess just leaving the files there is
ok. This removes the call to remove_package() and execs the prerm script
instead.

Hunk #3: dpkg_main(): In the code around checking for an existing
package there seem to be two problems: (i) The status hashtable entry must
not use the newly allocated status_node in both cases. If we already found
an existing package this entry is ok (and assigning the new status_node
causes a SEGV since it is only partially initialized). So I moved the
assignment in the then-clause of the if statement. (ii) When replacing the
package the status needs to be set to "install reinstreq
installed". Otherwise leaving it at "install ok installed" the function
write_status_file() would not take the new control file and thus, there
won't be the new version number in the status file.

I have done some testing with installing, replacing, listing and purging a
test package (with two versions 1.1 and 1.2) and this seems to work
fine. I hope this patch is ok with you.

Thanks,
-Stefan 

--
Stefan Soucek, ssoucek at coactive.com
Coactive Networks, 28 Liberty Ship Way, Sausalito, CA 94965
Ph: (415) 289 7840, Fax: (415) 289 1320

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dpkg-replace.diff
Url: http://lists.busybox.net/pipermail/busybox/attachments/20011005/69999f06/attachment.diff 


More information about the busybox mailing list