[BusyBox] [PATCH] dpkg replace pkg SEGV fix

Glenn McGrath bug1 at optushome.com.au
Fri Oct 5 21:00:42 UTC 2001


On Fri, 5 Oct 2001 13:44:31 -0700 
Stefan Soucek <ssoucek at coactive.com> wrote:

> 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.
> 
I agree with this one

> 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.
> 
Im not so sure about this, we still want to remove any files from the old
package that wernt overwritten.

> 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.
> 
Yes your right, i nearly didnt see the second part.

> 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.
> 

I will look into the second chunk further, and thanks again for finding all
these bugs.

Also, too keep you in the loop, ive started working on some changes to the
data structures, it should reduce memory usage and simplify the code
somewhat, making it easier to parse both /var/lib/dpkg/available (and
remember uninstabled packages from /var/lib/dpkg/status).
Once that is done big chunks can be seperated from dpkg and used also by
and apt-get style retriever.

These changes may be a week or so away, but i dont want to introduce more
bugs to the current code, so ill let you know when i have a patch worth
looking at.


Glenn






More information about the busybox mailing list