diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dpkg/arch.c | 4 | ||||
-rw-r--r-- | lib/dpkg/dbmodify.c | 18 | ||||
-rw-r--r-- | lib/dpkg/dump.c | 68 | ||||
-rw-r--r-- | lib/dpkg/file.c | 4 | ||||
-rw-r--r-- | lib/dpkg/parse.c | 6 | ||||
-rw-r--r-- | lib/dpkg/path-remove.c | 4 | ||||
-rw-r--r-- | lib/dpkg/pkg-array.c | 5 | ||||
-rw-r--r-- | lib/dpkg/pkg-db.c | 7 | ||||
-rw-r--r-- | lib/dpkg/pkg.c | 6 | ||||
-rw-r--r-- | lib/dpkg/triglib.c | 15 |
10 files changed, 90 insertions, 47 deletions
diff --git a/lib/dpkg/arch.c b/lib/dpkg/arch.c index 099957170..36b482972 100644 --- a/lib/dpkg/arch.c +++ b/lib/dpkg/arch.c @@ -23,7 +23,6 @@ #include <config.h> #include <compat.h> -#include <assert.h> #include <limits.h> #include <string.h> #include <stdbool.h> @@ -59,7 +58,8 @@ dpkg_arch_name_is_illegal(const char *name) static char buf[150]; const char *p = name; - assert(name); + if (name == NULL) + internerr("arch name argument is NULL"); if (!*p) return _("may not be empty string"); if (!c_isalnum(*p)) diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c index ec1102107..9baa58373 100644 --- a/lib/dpkg/dbmodify.c +++ b/lib/dpkg/dbmodify.c @@ -27,7 +27,6 @@ #include <sys/types.h> #include <sys/wait.h> -#include <assert.h> #include <errno.h> #include <limits.h> #include <string.h> @@ -307,13 +306,19 @@ modstatdb_get_status(void) void modstatdb_checkpoint(void) { int i; - assert(cstatus >= msdbrw_write); + if (cstatus < msdbrw_write) + internerr("modstatdb status '%d' is not writtable", cstatus); + writedb(statusfile, wdb_must_sync); for (i=0; i<nextupdate; i++) { sprintf(updatefnrest, IMPORTANTFMT, i); + /* Have we made a real mess? */ - assert(strlen(updatefnrest) <= IMPORTANTMAXLEN); + if (strlen(updatefnrest) > IMPORTANTMAXLEN) + internerr("modstatdb update entry name '%s' longer than %d", + updatefnrest, IMPORTANTMAXLEN); + if (unlink(updatefnbuf)) ohshite(_("failed to remove my own update file %.255s"),updatefnbuf); } @@ -349,7 +354,8 @@ void modstatdb_shutdown(void) { static void modstatdb_note_core(struct pkginfo *pkg) { - assert(cstatus >= msdbrw_write); + if (cstatus < msdbrw_write) + internerr("modstatdb status '%d' is not writtable", cstatus); varbuf_reset(&uvb); varbufrecord(&uvb, pkg, &pkg->installed); @@ -377,7 +383,9 @@ modstatdb_note_core(struct pkginfo *pkg) dir_sync_path(updatesdir); /* Have we made a real mess? */ - assert(strlen(updatefnrest) <= IMPORTANTMAXLEN); + if (strlen(updatefnrest) > IMPORTANTMAXLEN) + internerr("modstatdb update entry name '%s' longer than %d", + updatefnrest, IMPORTANTMAXLEN); nextupdate++; diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c index a04f673d9..8086cf77f 100644 --- a/lib/dpkg/dump.c +++ b/lib/dpkg/dump.c @@ -30,7 +30,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <string.h> #include <unistd.h> @@ -57,7 +56,9 @@ w_name(struct varbuf *vb, const struct pkginfo *pkg, const struct pkgbin *pkgbin, enum fwriteflags flags, const struct fieldinfo *fip) { - assert(pkg->set->name); + if (pkg->set->name == NULL) + internerr("pkgset has no name"); + if (flags&fw_printheader) varbuf_add_str(vb, "Package: "); varbuf_add_str(vb, pkg->set->name); @@ -230,7 +231,11 @@ w_priority(struct varbuf *vb, { if (pkg->priority == PKG_PRIO_UNKNOWN) return; - assert(pkg->priority <= PKG_PRIO_UNKNOWN); + + if (pkg->priority > PKG_PRIO_UNKNOWN) + internerr("package %s has out-of-range priority %d", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg->priority); + if (flags&fw_printheader) varbuf_add_str(vb, "Priority: "); varbuf_add_str(vb, pkg_priority_name(pkg)); @@ -245,38 +250,46 @@ w_status(struct varbuf *vb, { if (pkgbin != &pkg->installed) return; - assert(pkg->want <= PKG_WANT_PURGE); - assert(pkg->eflag <= PKG_EFLAG_REINSTREQ); -#define PEND pkg->trigpend_head -#define AW pkg->trigaw.head + if (pkg->want > PKG_WANT_PURGE) + internerr("package %s has unknown want state %d", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg->want); + if (pkg->eflag > PKG_EFLAG_REINSTREQ) + internerr("package %s has unknown error state %d", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg->eflag); + switch (pkg->status) { case PKG_STAT_NOTINSTALLED: case PKG_STAT_CONFIGFILES: - assert(!PEND); - assert(!AW); + if (pkg->trigpend_head || pkg->trigaw.head) + internerr("package %s in state %s, has awaited or pending triggers", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg_status_name(pkg)); break; case PKG_STAT_HALFINSTALLED: case PKG_STAT_UNPACKED: case PKG_STAT_HALFCONFIGURED: - assert(!PEND); + if (pkg->trigpend_head) + internerr("package %s in state %s, has pending triggers", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg_status_name(pkg)); break; case PKG_STAT_TRIGGERSAWAITED: - assert(AW); + if (pkg->trigaw.head == NULL) + internerr("package %s in state %s, has no awaited triggers", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg_status_name(pkg)); break; case PKG_STAT_TRIGGERSPENDING: - assert(PEND); - assert(!AW); + if (pkg->trigpend_head == NULL || pkg->trigaw.head) + internerr("package %s in stata %s, has awaited or no pending triggers", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg_status_name(pkg)); break; case PKG_STAT_INSTALLED: - assert(!PEND); - assert(!AW); + if (pkg->trigpend_head || pkg->trigaw.head) + internerr("package %s in state %s, has awaited or pending triggers", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg_status_name(pkg)); break; default: internerr("unknown package status '%d'", pkg->status); } -#undef PEND -#undef AW if (flags&fw_printheader) varbuf_add_str(vb, "Status: "); @@ -295,7 +308,9 @@ void varbufdependency(struct varbuf *vb, struct dependency *dep) { possdel= ""; for (dop= dep->list; dop; dop= dop->next) { - assert(dop->up == dep); + if (dop->up != dep) + internerr("dependency and deppossi not linked properly"); + varbuf_add_str(vb, possdel); possdel = " | "; varbuf_add_str(vb, dop->ed->name); @@ -339,7 +354,10 @@ w_dependency(struct varbuf *vb, for (dyp = pkgbin->depends; dyp; dyp = dyp->next) { if (dyp->type != fip->integer) continue; - assert(dyp->up == pkg); + + if (dyp->up != pkg) + internerr("dependency and package %s not linked properly", + pkgbin_name(pkg, pkgbin, pnaw_always)); if (dep_found) { varbuf_add_str(vb, ", "); @@ -389,8 +407,10 @@ w_trigpend(struct varbuf *vb, if (pkgbin == &pkg->available || !pkg->trigpend_head) return; - assert(pkg->status >= PKG_STAT_TRIGGERSAWAITED && - pkg->status <= PKG_STAT_TRIGGERSPENDING); + if (pkg->status < PKG_STAT_TRIGGERSAWAITED || + pkg->status > PKG_STAT_TRIGGERSPENDING) + internerr("package %s in non-trigger state %s, has pending triggers", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg_status_name(pkg)); if (flags & fw_printheader) varbuf_add_str(vb, "Triggers-Pending:"); @@ -412,8 +432,10 @@ w_trigaw(struct varbuf *vb, if (pkgbin == &pkg->available || !pkg->trigaw.head) return; - assert(pkg->status > PKG_STAT_CONFIGFILES && - pkg->status <= PKG_STAT_TRIGGERSAWAITED); + if (pkg->status <= PKG_STAT_CONFIGFILES || + pkg->status > PKG_STAT_TRIGGERSAWAITED) + internerr("package %s in state %s, has awaited triggers", + pkgbin_name(pkg, pkgbin, pnaw_always), pkg_status_name(pkg)); if (flags & fw_printheader) varbuf_add_str(vb, "Triggers-Awaited:"); diff --git a/lib/dpkg/file.c b/lib/dpkg/file.c index f8afdeb8a..cd261222c 100644 --- a/lib/dpkg/file.c +++ b/lib/dpkg/file.c @@ -25,7 +25,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> @@ -79,7 +78,8 @@ file_unlock(int lockfd, const char *lock_desc) { struct flock fl; - assert(lockfd >= 0); + if (lockfd < 0) + internerr("lock fd is %d < 0", lockfd); file_lock_setup(&fl, F_UNLCK); diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c index d75c54458..221067881 100644 --- a/lib/dpkg/parse.c +++ b/lib/dpkg/parse.c @@ -28,7 +28,6 @@ #include <sys/mman.h> #endif -#include <assert.h> #include <fcntl.h> #include <string.h> #include <unistd.h> @@ -493,7 +492,10 @@ pkg_parse_copy(struct parsedb_state *ps, dst_pkg->trigpend_head = src_pkg->trigpend_head; dst_pkg->trigaw = src_pkg->trigaw; for (ta = dst_pkg->trigaw.head; ta; ta = ta->sameaw.next) { - assert(ta->aw == src_pkg); + if (ta->aw != src_pkg) + internerr("trigger awaited package %s and origin package %s not linked properly", + pkg_name(ta->aw, pnaw_always), + pkgbin_name(src_pkg, src_pkgbin, pnaw_always)); ta->aw = dst_pkg; /* ->othertrigaw_head is updated by trig_note_aw in *(pkg_db_find()) * rather than in dst_pkg. */ diff --git a/lib/dpkg/path-remove.c b/lib/dpkg/path-remove.c index ab26b4a8d..ef9cde7b5 100644 --- a/lib/dpkg/path-remove.c +++ b/lib/dpkg/path-remove.c @@ -24,7 +24,6 @@ #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <string.h> #include <unistd.h> @@ -122,7 +121,8 @@ path_remove_tree(const char *pathname) const char *u; u = path_skip_slash_dotslash(pathname); - assert(*u); + if (u[0] == '\0') + internerr("pathname '%s' reduces to nothing", pathname); debug(dbg_eachfile, "%s '%s'", __func__, pathname); if (!rmdir(pathname)) diff --git a/lib/dpkg/pkg-array.c b/lib/dpkg/pkg-array.c index 24c6dc0e2..cf5c34d3f 100644 --- a/lib/dpkg/pkg-array.c +++ b/lib/dpkg/pkg-array.c @@ -22,7 +22,6 @@ #include <config.h> #include <compat.h> -#include <assert.h> #include <string.h> #include <stdlib.h> @@ -74,7 +73,9 @@ pkg_array_init_from_db(struct pkg_array *a) a->pkgs[i] = pkg; pkg_db_iter_free(iter); - assert(i == a->n_pkgs); + if (i != a->n_pkgs) + internerr("inconsistent state in pkg array: i=%d != npkgs=%d", + i, a->n_pkgs); } /** diff --git a/lib/dpkg/pkg-db.c b/lib/dpkg/pkg-db.c index 300c1cad8..7135450a3 100644 --- a/lib/dpkg/pkg-db.c +++ b/lib/dpkg/pkg-db.c @@ -24,7 +24,6 @@ #include <config.h> #include <compat.h> -#include <assert.h> #include <string.h> #include <stdlib.h> @@ -171,8 +170,10 @@ pkg_db_get_pkg(struct pkgset *set, const struct dpkg_arch *arch) { struct pkginfo *pkg, **pkgp; - assert(arch); - assert(arch->type != DPKG_ARCH_NONE); + if (arch == NULL) + internerr("arch argument is NULL"); + if (arch->type == DPKG_ARCH_NONE) + internerr("arch argument is none"); pkg = &set->pkg; diff --git a/lib/dpkg/pkg.c b/lib/dpkg/pkg.c index 1fc3d0c21..4141fddb2 100644 --- a/lib/dpkg/pkg.c +++ b/lib/dpkg/pkg.c @@ -22,9 +22,9 @@ #include <config.h> #include <compat.h> -#include <assert.h> #include <string.h> +#include <dpkg/ehandle.h> #include <dpkg/string.h> #include <dpkg/dpkg-db.h> #include <dpkg/pkg.h> @@ -42,7 +42,9 @@ pkg_set_status(struct pkginfo *pkg, enum pkgstatus status) else if (status == PKG_STAT_NOTINSTALLED) pkg->set->installed_instances--; - assert(pkg->set->installed_instances >= 0); + if (pkg->set->installed_instances < 0) + internerr("pkgset %s went into negative installed instances %d", + pkg->set->name, pkg->set->installed_instances); pkg->status = status; } diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c index 57bd2a66b..a067d1450 100644 --- a/lib/dpkg/triglib.c +++ b/lib/dpkg/triglib.c @@ -26,7 +26,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> @@ -104,7 +103,9 @@ trig_clear_awaiters(struct pkginfo *notpend) struct trigaw *ta; struct pkginfo *aw; - assert(!notpend->trigpend_head); + if (notpend->trigpend_head) + internerr("package %s has pending triggers", + pkg_name(notpend, pnaw_always)); ta = notpend->othertrigaw_head; notpend->othertrigaw_head = NULL; @@ -400,7 +401,10 @@ trk_file_interest_change(const char *trig, struct pkginfo *pkg, fnn = trigh.namenode_find(trig, signum <= 0); if (!fnn) { - assert(signum < 0); + if (signum >= 0) + internerr("lost filename node '%s' for package %s " + "triggered to add", trig, + pkgbin_name(pkg, pkgbin, pnaw_always)); return; } @@ -627,7 +631,10 @@ trig_cicb_interest_change(const char *trig, struct pkginfo *pkg, { const struct trigkindinfo *tki = trig_classify_byname(trig); - assert(filetriggers_edited >= 0); + if (filetriggers_edited < 0) + internerr("trigger control file for package %s not read", + pkgbin_name(pkg, pkgbin, pnaw_always)); + tki->interest_change(trig, pkg, pkgbin, signum, opts); } |