Subject: pkg_delete seg faulting when -O option used
To: None <current-users@NetBSD.org>
From: D'Arcy" "J.M. <darcy@druid.druid.net>
List: current-users
Date: 09/21/1999 16:50:50
I get a segfault on pkg_delete whenever I pass the -O option (i.e. when
defining FORCE_PKG_REGISTER while installing) and I have identified the
area where it happens but I am not sure what the fix is.  Here is the
code in question from main.c from line 181.

        error = 0;  
        while ((key = pkgdb_iter())) {
            val = pkgdb_retrieve(key);
            if (!val) continue;			/* ADDED BY ME */

            lpp = TAILQ_FIRST(&pkgs);
            if (lpp != NULL) {
                do {            
                    if (strcmp(val, lpp->lp_name) == 0) {
                        if (Verbose)
                            printf("Removing file %s from pkgdb\n", key);
...etc.

I fixed it by added the indicated line but I don't know if there is
some other issue that this hides.  I will dig deeper when I have
some time and file a PR but in the meantime if someone more familiar
with this code sees the correct fix, please go ahead.  Just drop me
a line so I know I don't have to later.

Interestingly I saw the same symptoms on a FreeBSD box.  So who is blindly
copying whom?  :-)

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.