From 5a1ebaccd57b157b70bcd1277f66c5d97e94edf1 Mon Sep 17 00:00:00 2001 From: jbj Date: Sun, 28 Jul 2002 14:52:33 +0000 Subject: [PATCH] - python: don't segfault in ts.GetKeys() on erased packages. resurrect build modes. add undocumented debugging options. CVS patchset: 5577 CVS date: 2002/07/28 14:52:33 --- CHANGES | 1 + build.c | 12 ++++++++ build/poptBT.c | 22 +++++++++++++- lib/package.c | 2 ++ lib/poptALL.c | 54 ++++++++++++++++++++++++++++++--- lib/rpmcli.h | 91 ++++++++++++++++++++++++++++--------------------------- lib/rpmps.c | 6 ++-- lib/rpmps.h | 5 +++ lib/rpmts.c | 6 ++-- lib/rpmts.h | 6 ++-- lib/transaction.c | 20 +++++++++--- macros.in | 5 +-- popt/popt.h | 2 ++ popt/popthelp.c | 40 +++++++++++++----------- python/rpmts-py.c | 8 +++-- rpm.spec.in | 1 + rpmdb/rpmdb.c | 10 +++--- rpmdb/rpmdb.h | 5 +++ rpmqv.c | 12 ++++---- 19 files changed, 212 insertions(+), 96 deletions(-) diff --git a/CHANGES b/CHANGES index bffcf8a..f723265 100644 --- a/CHANGES +++ b/CHANGES @@ -189,6 +189,7 @@ - fix: rpm2cpio disables signature checks (i.e. same behavior). - popt: display sub-table options only once on --usage. - wire --nosignatures et al as common options, rework CLI options. + - python: don't segfault in ts.GetKeys() on erased packages. 4.0.3 -> 4.0.4: - solaris: translate i86pc to i386 (#57182). diff --git a/build.c b/build.c index 4265908..10a8e7c 100644 --- a/build.c +++ b/build.c @@ -298,6 +298,17 @@ int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile) char * targets = ba->targets; #define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC) int cleanFlags = ba->buildAmount & buildCleanMask; + int vsflags, ovsflags; + + vsflags = rpmExpandNumeric("%{_vsflags_build}"); + if (ba->qva_flags & VERIFY_DIGEST) + vsflags |= _RPMTS_VSF_NODIGESTS; + if (ba->qva_flags & VERIFY_SIGNATURE) + vsflags |= _RPMTS_VSF_NOSIGNATURES; + if (ba->qva_flags & VERIFY_HDRCHK) + vsflags |= _RPMTS_VSF_NOHDRCHK; +fprintf(stderr, "*** vsflags 0x%x qva_flags 0x%x\n", vsflags, ba->qva_flags); + ovsflags = rpmtsSetVerifySigFlags(ts, vsflags); if (targets == NULL) { rc = buildForTarget(ts, arg, ba); @@ -332,6 +343,7 @@ int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile) } exit: + vsflags = rpmtsSetVerifySigFlags(ts, ovsflags); /* Restore original configuration. */ rpmFreeMacros(NULL); (void) rpmReadConfigFiles(rcfile, NULL); diff --git a/build/poptBT.c b/build/poptBT.c index 179a40d..6314eac 100644 --- a/build/poptBT.c +++ b/build/poptBT.c @@ -89,7 +89,7 @@ static void buildArgCallback( /*@unused@*/ poptContext con, case POPT_TL: case POPT_TP: case POPT_TS: - if (rba->buildMode == ' ') { + if (rba->buildMode == '\0' && rba->buildChar == '\0') { rba->buildMode = (((unsigned)opt->val) >> 8) & 0xff; rba->buildChar = (opt->val ) & 0xff; } @@ -122,6 +122,18 @@ static void buildArgCallback( /*@unused@*/ poptContext con, strcat(rba->targets, arg); break; + case RPMCLI_POPT_NODIGEST: + rba->qva_flags |= VERIFY_DIGEST; + break; + + case RPMCLI_POPT_NOSIGNATURE: + rba->qva_flags |= VERIFY_SIGNATURE; + break; + + case RPMCLI_POPT_NOHDRCHK: + rba->qva_flags |= VERIFY_HDRCHK; + break; + case RPMCLI_POPT_NODEPS: rba->noDeps = 1; break; @@ -212,6 +224,14 @@ struct poptOption rpmBuildPoptTable[] = { { "nodirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 1, N_("generate package header(s) compatible with (legacy) rpm[23] packaging"), NULL}, + + { "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NODIGEST, + N_("don't verify package digest(s)"), NULL }, + { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK, + N_("don't verify database header(s) when retrieved"), NULL }, + { "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOSIGNATURE, + N_("don't verify package signature(s)"), NULL }, + { "nolang", '\0', POPT_ARGFLAG_DOC_HIDDEN, &noLang, POPT_NOLANG, N_("do not accept i18N msgstr's from specfile"), NULL}, { "rmsource", '\0', 0, 0, POPT_RMSOURCE, diff --git a/lib/package.c b/lib/package.c index 0ff90c9..7de0976 100644 --- a/lib/package.c +++ b/lib/package.c @@ -297,7 +297,9 @@ rpmRC headerCheck(rpmts ts, const void * uh, size_t uc, const char ** msg) /*@-boundsread@*/ int_32 il = ntohl(ei[0]); int_32 dl = ntohl(ei[1]); +/*@-castexpose@*/ entryInfo pe = (entryInfo) &ei[2]; +/*@=castexpose@*/ /*@=boundsread@*/ int_32 ildl[2]; int_32 pvlen = sizeof(ildl) + (il * sizeof(*pe)) + dl; diff --git a/lib/poptALL.c b/lib/poptALL.c index 65c97dd..b90576f 100644 --- a/lib/poptALL.c +++ b/lib/poptALL.c @@ -20,6 +20,33 @@ static int _debug = 0; /*@-exportheadervar@*/ /*@unchecked@*/ +extern int _fps_debug; + +/*@unchecked@*/ +extern int _fsm_debug; + +/*@unchecked@*/ +extern int _rpmal_debug; + +/*@unchecked@*/ +extern int _rpmdb_debug; + +/*@unchecked@*/ +extern int _rpmds_debug; + +/*@unchecked@*/ +extern int _rpmfi_debug; + +/*@unchecked@*/ +extern int _rpmps_debug; + +/*@unchecked@*/ +extern int _rpmte_debug; + +/*@unchecked@*/ +extern int _rpmts_debug; + +/*@unchecked@*/ extern int noLibio; /*@=exportheadervar@*/ @@ -49,7 +76,7 @@ extern int _rpmio_debug; */ static void printVersion(FILE * fp) /*@globals rpmEVR, fileSystem @*/ - /*@modifies fileSystem @*/ + /*@modifies *fp, fileSystem @*/ { fprintf(fp, _("RPM version %s\n"), rpmEVR); } @@ -80,9 +107,9 @@ static void rpmcliAllArgCallback( /*@unused@*/ poptContext con, /*@unused@*/ enum poptCallbackReason reason, const struct poptOption * opt, const char * arg, /*@unused@*/ const void * data) - /*@globals rpmCLIMacroContext, rpmGlobalMacroContext, + /*@globals rpmcliQueryFlags, rpmCLIMacroContext, rpmGlobalMacroContext, fileSystem, internalState @*/ - /*@modifies rpmCLIMacroContext, rpmGlobalMacroContext, + /*@modifies rpmcliQueryFlags, rpmCLIMacroContext, rpmGlobalMacroContext, fileSystem, internalState @*/ { @@ -187,8 +214,7 @@ struct poptOption rpmcliAllPoptTable[] = { N_("ROOT") }, { "showrc", '\0', 0, NULL, POPT_SHOWRC, - N_("display final rpmrc and macro configuration"), - NULL }, + N_("display final rpmrc and macro configuration"), NULL }, { "quiet", '\0', 0, NULL, 'q', N_("provide less detailed output"), NULL}, { "verbose", 'v', 0, NULL, 'v', @@ -201,14 +227,32 @@ struct poptOption rpmcliAllPoptTable[] = { N_("disable use of libio(3) API"), NULL}, #endif + { "fpsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_fps_debug, -1, + NULL, NULL}, + { "fsmdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_fsm_debug, -1, + N_("debug payload file state machine"), NULL}, { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1, N_("debug protocol data stream"), NULL}, #ifdef DYING { "poptdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_popt_debug, -1, N_("debug option/argument processing"), NULL}, #endif + { "rpmaldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmal_debug, -1, + NULL, NULL}, + { "rpmdbdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmdb_debug, -1, + NULL, NULL}, + { "rpmdsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmds_debug, -1, + NULL, NULL}, + { "rpmfidebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmfi_debug, -1, + NULL, NULL}, { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, N_("debug rpmio I/O"), NULL}, + { "rpmpsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmps_debug, -1, + NULL, NULL}, + { "rpmtedebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmte_debug, -1, + NULL, NULL}, + { "rpmtsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmts_debug, -1, + NULL, NULL}, { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, N_("debug URL cache handling"), NULL}, diff --git a/lib/rpmcli.h b/lib/rpmcli.h index f0eee64..1ebf5e4 100644 --- a/lib/rpmcli.h +++ b/lib/rpmcli.h @@ -83,51 +83,6 @@ rpmcliFini(/*@only@*/ /*@null@*/ poptContext optCon) #define RPMCLI_POPT_NOHDRCHK -1031 /* ==================================================================== */ -/** \name RPMBT */ -/*@{*/ - -/** \ingroup rpmcli - * Describe build command line request. - */ -struct rpmBuildArguments_s { - int buildAmount; /*!< Bit(s) to control operation. */ -/*@null@*/ - const char * buildRootOverride; /*!< from --buildroot */ -/*@null@*/ - char * targets; /*!< Target platform(s), comma separated. */ -/*@observer@*/ - const char * passPhrase; /*!< Pass phrase. */ -/*@only@*/ /*@null@*/ - const char * cookie; /*!< NULL for binary, ??? for source, rpm's */ - int force; /*!< from --force */ - int noBuild; /*!< from --nobuild */ - int noDeps; /*!< from --nodeps */ - int noLang; /*!< from --nolang */ - int shortCircuit; /*!< from --short-circuit */ - int sign; /*!< from --sign */ - int useCatalog; /*!< from --usecatalog */ - char buildMode; /*!< Build mode (one of "btBC") */ - char buildChar; /*!< Build stage (one of "abcilps ") */ -/*@observer@*/ /*@null@*/ - const char * rootdir; -}; - -/** \ingroup rpmcli - */ -typedef struct rpmBuildArguments_s * BTA_t; - -/** \ingroup rpmcli - */ -/*@unchecked@*/ -extern struct rpmBuildArguments_s rpmBTArgs; - -/** \ingroup rpmcli - */ -/*@unchecked@*/ -extern struct poptOption rpmBuildPoptTable[]; - -/*@}*/ -/* ==================================================================== */ /** \name RPMQV */ /*@{*/ @@ -456,6 +411,52 @@ int rpmcliVerify(rpmts ts, QVA_t qva, /*@null@*/ const char ** argv) /*@}*/ /* ==================================================================== */ +/** \name RPMBT */ +/*@{*/ + +/** \ingroup rpmcli + * Describe build command line request. + */ +struct rpmBuildArguments_s { + rpmQueryFlags qva_flags; /*!< Bit(s) to control verification. */ + int buildAmount; /*!< Bit(s) to control operation. */ +/*@null@*/ + const char * buildRootOverride; /*!< from --buildroot */ +/*@null@*/ + char * targets; /*!< Target platform(s), comma separated. */ +/*@observer@*/ + const char * passPhrase; /*!< Pass phrase. */ +/*@only@*/ /*@null@*/ + const char * cookie; /*!< NULL for binary, ??? for source, rpm's */ + int force; /*!< from --force */ + int noBuild; /*!< from --nobuild */ + int noDeps; /*!< from --nodeps */ + int noLang; /*!< from --nolang */ + int shortCircuit; /*!< from --short-circuit */ + int sign; /*!< from --sign */ + int useCatalog; /*!< from --usecatalog */ + char buildMode; /*!< Build mode (one of "btBC") */ + char buildChar; /*!< Build stage (one of "abcilps ") */ +/*@observer@*/ /*@null@*/ + const char * rootdir; +}; + +/** \ingroup rpmcli + */ +typedef struct rpmBuildArguments_s * BTA_t; + +/** \ingroup rpmcli + */ +/*@unchecked@*/ +extern struct rpmBuildArguments_s rpmBTArgs; + +/** \ingroup rpmcli + */ +/*@unchecked@*/ +extern struct poptOption rpmBuildPoptTable[]; + +/*@}*/ +/* ==================================================================== */ /** \name RPMEIU */ /*@{*/ /* --- install/upgrade/erase modes */ diff --git a/lib/rpmps.c b/lib/rpmps.c index 2a3898b..4afb871 100644 --- a/lib/rpmps.c +++ b/lib/rpmps.c @@ -15,13 +15,13 @@ /*@access rpmProblem @*/ /*@unchecked@*/ -static int _ps_debug = 0; +int _rpmps_debug = 0; rpmps XrpmpsUnlink(rpmps ps, const char * msg, const char * fn, unsigned ln) { /*@-modfilesystem@*/ -if (_ps_debug > 0 && msg != NULL) +if (_rpmps_debug > 0 && msg != NULL) fprintf(stderr, "--> ps %p -- %d %s at %s:%u\n", ps, ps->nrefs, msg, fn, ln); /*@=modfilesystem@*/ ps->nrefs--; @@ -35,7 +35,7 @@ rpmps XrpmpsLink(rpmps ps, const char * msg, { ps->nrefs++; /*@-modfilesystem@*/ -if (_ps_debug > 0 && msg != NULL) +if (_rpmps_debug > 0 && msg != NULL) fprintf(stderr, "--> ps %p ++ %d %s at %s:%u\n", ps, ps->nrefs, msg, fn, ln); /*@=modfilesystem@*/ /*@-refcounttrans@*/ diff --git a/lib/rpmps.h b/lib/rpmps.h index 4f110a5..dcbc259 100644 --- a/lib/rpmps.h +++ b/lib/rpmps.h @@ -6,6 +6,11 @@ * Structures and prototypes used for an "rpmps" problem set. */ +/*@-exportlocal@*/ +/*@unchecked@*/ +extern int _rpmps_debug; +/*@=exportlocal@*/ + /** * Raw data for an element of a problem set. */ diff --git a/lib/rpmts.c b/lib/rpmts.c index 86919ec..70d4c7b 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -63,7 +63,7 @@ extern int statvfs (const char * file, /*@out@*/ struct statvfs * buf) /*@access pgpDigParams @*/ /*@unchecked@*/ -int _ts_debug = 0; +int _rpmts_debug = 0; char * hGetNEVR(Header h, const char ** np) { @@ -87,7 +87,7 @@ char * hGetNEVR(Header h, const char ** np) rpmts XrpmtsUnlink(rpmts ts, const char * msg, const char * fn, unsigned ln) { /*@-modfilesystem@*/ -if (_ts_debug) +if (_rpmts_debug) fprintf(stderr, "--> ts %p -- %d %s at %s:%u\n", ts, ts->nrefs, msg, fn, ln); /*@=modfilesystem@*/ ts->nrefs--; @@ -98,7 +98,7 @@ rpmts XrpmtsLink(rpmts ts, const char * msg, const char * fn, unsigned ln) { ts->nrefs++; /*@-modfilesystem@*/ -if (_ts_debug) +if (_rpmts_debug) fprintf(stderr, "--> ts %p ++ %d %s at %s:%u\n", ts, ts->nrefs, msg, fn, ln); /*@=modfilesystem@*/ /*@-refcounttrans@*/ return ts; /*@=refcounttrans@*/ diff --git a/lib/rpmts.h b/lib/rpmts.h index f562bc5..294fa42 100644 --- a/lib/rpmts.h +++ b/lib/rpmts.h @@ -8,9 +8,11 @@ #include "rpmps.h" -/*@unchecked@*/ /*@-exportlocal@*/ -extern int _ts_debug; +/*@unchecked@*/ +extern int _rpmts_debug; +/*@unchecked@*/ +extern int _fps_debug; /*@=exportlocal@*/ #define _RPMTS_VSF_NODIGESTS (1 << 0) diff --git a/lib/transaction.c b/lib/transaction.c index 9efe99b..61ff5d6 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -141,22 +141,26 @@ static fileAction decideFileFate(const rpmts ts, if (domd5(fn, buffer, 0, NULL)) return FA_CREATE; /* assume file has been removed */ omd5 = rpmfiMD5(ofi); - if (!memcmp(omd5, buffer, 16)) + if (omd5 && !memcmp(omd5, buffer, 16)) return FA_CREATE; /* unmodified config file, replace. */ nmd5 = rpmfiMD5(nfi); - if (!memcmp(omd5, nmd5, 16)) +/*@-nullpass@*/ + if (omd5 && nmd5 && !memcmp(omd5, nmd5, 16)) return FA_SKIP; /* identical file, don't bother. */ +/*@=nullpass@*/ } else /* dbWhat == LINK */ { const char * oFLink, * nFLink; memset(buffer, 0, sizeof(buffer)); if (readlink(fn, buffer, sizeof(buffer) - 1) == -1) return FA_CREATE; /* assume file has been removed */ oFLink = rpmfiFLink(ofi); - if (!strcmp(oFLink, buffer)) + if (oFLink && !strcmp(oFLink, buffer)) return FA_CREATE; /* unmodified config file, replace. */ nFLink = rpmfiFLink(nfi); - if (!strcmp(oFLink, nFLink)) +/*@-nullpass@*/ + if (oFLink && nFLink && !strcmp(oFLink, nFLink)) return FA_SKIP; /* identical file, don't bother. */ +/*@=nullpass@*/ } /* @@ -183,10 +187,16 @@ static int filecmp(rpmfi afi, rpmfi bfi) if (awhat == LINK) { const char * alink = rpmfiFLink(afi); const char * blink = rpmfiFLink(bfi); + if (alink == blink) return 0; + if (alink == NULL) return 1; + if (blink == NULL) return -1; return strcmp(alink, blink); } else if (awhat == REG) { const unsigned char * amd5 = rpmfiMD5(afi); const unsigned char * bmd5 = rpmfiMD5(bfi); + if (amd5 == bmd5) return 0; + if (amd5 == NULL) return 1; + if (bmd5 == NULL) return -1; return memcmp(amd5, bmd5, 16); } @@ -334,7 +344,7 @@ static int handleRmvdInstalledFiles(const rpmts ts, rpmfi fi, #define ISROOT(_d) (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d)) /*@unchecked@*/ -static int _fps_debug = 0; +int _fps_debug = 0; static int fpsCompare (const void * one, const void * two) /*@*/ diff --git a/macros.in b/macros.in index 158ee98..446e703 100644 --- a/macros.in +++ b/macros.in @@ -1,7 +1,7 @@ #/*! \page config_macros Default configuration: /usr/lib/rpm/macros # \verbatim # -# $Id: macros.in,v 1.111 2002/07/24 16:21:23 jbj Exp $ +# $Id: macros.in,v 1.112 2002/07/28 14:52:33 jbj Exp $ # # This is a global RPM configuration file. All changes made here will # be lost when the rpm package is upgraded. Any per-system configuration @@ -552,8 +552,9 @@ # Note: the %_vsflags_erase applies to --upgrade/--freshen modes as # well as --erase. # -%_vsflags_install 8 +%_vsflags_build 8 %_vsflags_erase 8 +%_vsflags_install 8 %_vsflags_query 8 %_vsflags_rebuilddb 0 %_vsflags_verify 0 diff --git a/popt/popt.h b/popt/popt.h index c1a3115..7e87e86 100644 --- a/popt/popt.h +++ b/popt/popt.h @@ -232,8 +232,10 @@ typedef void (*poptCallbackType) (poptContext con, * Reinitialize popt context. * @param con context */ +/*@-exportlocal@*/ void poptResetContext(/*@null@*/poptContext con) /*@modifies con @*/; +/*@=exportlocal@*/ /** \ingroup popt * Return value of next option found. diff --git a/popt/popthelp.c b/popt/popthelp.c index f40b740..6b07e34 100644 --- a/popt/popthelp.c +++ b/popt/popthelp.c @@ -554,7 +554,7 @@ static int singleOptionUsage(FILE * fp, int cursor, cursor = 7; } - if (opt->shortName && opt->longName) { + if (opt->longName && opt->shortName) { fprintf(fp, " [-%c|-%s%s%s%s]", opt->shortName, ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "" : "-"), opt->longName, @@ -609,7 +609,6 @@ static int itemUsage(FILE * fp, int cursor, poptItem item, int nitems, typedef struct poptDone_s { int nopts; int maxopts; -/*@observer@*/ const void ** opts; } * poptDone; @@ -623,12 +622,12 @@ typedef struct poptDone_s { * @param done tables already processed * @return */ -static int singleTableUsage(poptContext con, FILE * fp, - int cursor, const struct poptOption * opt, +static int singleTableUsage(poptContext con, FILE * fp, int cursor, + /*@null@*/ const struct poptOption * opt, /*@null@*/ const char * translation_domain, - poptDone done) + /*@null@*/ poptDone done) /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/ + /*@modifies *fp, done, fileSystem @*/ { /*@-branchstate@*/ /* FIX: W2DO? */ if (opt != NULL) @@ -636,19 +635,24 @@ static int singleTableUsage(poptContext con, FILE * fp, if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) { translation_domain = (const char *)opt->arg; } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - int i = 0; - if (done) - for (i = 0; i < done->nopts; i++) { - const void * that = done->opts[i]; - if (that == NULL || that != opt->arg) + if (done) { + int i = 0; + for (i = 0; i < done->nopts; i++) { +/*@-boundsread@*/ + const void * that = done->opts[i]; +/*@=boundsread@*/ + if (that == NULL || that != opt->arg) + /*@innercontinue@*/ continue; + /*@innerbreak@*/ break; + } + /* Skip if this table has already been processed. */ + if (opt->arg == NULL || i < done->nopts) continue; - break; +/*@-boundswrite@*/ + if (done->nopts < done->maxopts) + done->opts[done->nopts++] = (const void *) opt->arg; +/*@=boundswrite@*/ } - /* Skip if this table has already been processed. */ - if (opt->arg == NULL || i < done->nopts) - continue; - if (done->nopts < done->maxopts) - done->opts[done->nopts++] = (const void *) opt->arg; cursor = singleTableUsage(con, fp, cursor, opt->arg, translation_domain, done); } else if ((opt->longName || opt->shortName) && @@ -710,8 +714,10 @@ void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags) done->nopts = 0; done->maxopts = 64; cursor = done->maxopts * sizeof(*done->opts); +/*@-boundswrite@*/ done->opts = memset(alloca(cursor), 0, cursor); done->opts[done->nopts++] = (const void *) con->options; +/*@=boundswrite@*/ cursor = showHelpIntro(con, fp); cursor += showShortOptions(con->options, fp, NULL); diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 30bbc08..a947f21 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -530,7 +530,8 @@ fprintf(stderr, "*** GetKeys(%p) ts %p\n", s, s->ts); if (!PyArg_ParseTuple(args, ":GetKeys")) return NULL; rpmtsGetKeys(s->ts, &data, &num); - if (data == NULL) { + if (data == NULL || num <= 0) { + data = _free(data); Py_INCREF(Py_None); return Py_None; } @@ -538,12 +539,13 @@ fprintf(stderr, "*** GetKeys(%p) ts %p\n", s, s->ts); tuple = PyTuple_New(num); for (i = 0; i < num; i++) { - PyObject *obj = (PyObject *) data[i]; + PyObject *obj; + obj = (data[i] ? (PyObject *) data[i] : Py_None); Py_INCREF(obj); PyTuple_SetItem(tuple, i, obj); } - free (data); + data = _free(data); return tuple; } diff --git a/rpm.spec.in b/rpm.spec.in index 3b0d44b..d7f5437 100644 --- a/rpm.spec.in +++ b/rpm.spec.in @@ -518,6 +518,7 @@ fi * Sat Jul 27 2002 Jeff Johnson 4.1-0.58 - popt: display sub-table options only once on --usage. - wire --nosignatures et al as common options, rework CLI options. +- python: don't segfault in ts.GetKeys() on erased packages. * Thu Jul 25 2002 Jeff Johnson 4.1-0.57 - python: remove the old initdb/rebuilddb methods, use ts.fooDB(). diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index e30c3ab..2f49ba9 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -7,7 +7,7 @@ #define _USE_COPY_LOAD /* XXX don't use DB_DBT_MALLOC (yet) */ /*@unchecked@*/ -static int _rpmdb_debug = 0; +int _rpmdb_debug = 0; #include #include @@ -100,7 +100,9 @@ static inline pbm_set * PBM_REALLOC(pbm_set ** sp, int * odp, int nd) if (nd > (*odp)) { nd *= 2; nb = __PBM_IX(nd) + 1; +/*@-unqualifiedtrans@*/ *sp = xrealloc(*sp, nb * sizeof(__pbm_bits)); +/*@=unqualifiedtrans@*/ for (i = __PBM_IX(*odp) + 1; i < nb; i++) __PBM_BITS(*sp)[i] = 0; *odp = nd; @@ -2114,7 +2116,7 @@ top: /* Check header digest/signature once (if requested). */ /*@-boundsread -branchstate -sizeoftype @*/ - if (mi->mi_ts && mi->mi_hdrchk) { + if (mi->mi_hdrchk && mi->mi_ts) { const char * msg = NULL; pbm_set * set = NULL; rpmRC rpmrc = RPMRC_NOTFOUND; @@ -2124,7 +2126,7 @@ top: &mi->mi_db->db_nbits, mi->mi_offset); if (PBM_ISSET(mi->mi_offset, set)) { #ifdef NOISY - rpmMessage(RPMMESS_DEBUG, _("h#%6u: already checked.\n"), + rpmMessage(RPMMESS_DEBUG, _("h#%7u: already checked.\n"), mi->mi_offset); #endif rpmrc = RPMRC_OK; @@ -2133,7 +2135,7 @@ top: if (rpmrc == RPMRC_NOTFOUND) { rpmrc = (*mi->mi_hdrchk) (mi->mi_ts, uh, uhlen, &msg); if (msg) - rpmMessage(RPMMESS_DEBUG, _("h#%6u: %s"), + rpmMessage(RPMMESS_DEBUG, _("h#%7u: %s"), mi->mi_offset, msg); if (set && rpmrc == RPMRC_OK) PBM_SET(mi->mi_offset, set); diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h index 920205c..86a9329 100644 --- a/rpmdb/rpmdb.h +++ b/rpmdb/rpmdb.h @@ -11,6 +11,11 @@ #include #include +/*@-exportlocal@*/ +/*@unchecked@*/ +extern int _rpmdb_debug; +/*@=exportlocal@*/ + #ifdef NOTYET /** \ingroup rpmdb * Database of headers and tag value indices. diff --git a/rpmqv.c b/rpmqv.c index 4dcd5be..47269bf 100755 --- a/rpmqv.c +++ b/rpmqv.c @@ -130,22 +130,22 @@ long _stksize = 64 * 1024L; static void printVersion(FILE * fp) /*@globals rpmEVR, fileSystem @*/ - /*@modifies fileSystem @*/ + /*@modifies *fp, fileSystem @*/ { fprintf(fp, _("RPM version %s\n"), rpmEVR); } static void printBanner(FILE * fp) /*@globals fileSystem @*/ - /*@modifies fileSystem @*/ + /*@modifies *fp, fileSystem @*/ { fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n")); fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n")); } static void printUsage(poptContext con, FILE * fp, int flags) - /*@globals __assert_program_name, rpmEVR, fileSystem @*/ - /*@modifies fileSystem @*/ + /*@globals rpmEVR, fileSystem, internalState @*/ + /*@modifies *fp, fileSystem, internalState @*/ { printVersion(fp); printBanner(fp); @@ -789,9 +789,9 @@ ia->transFlags |= RPMTRANS_FLAG_NOMD5; ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE; /*@i@*/ ec += rpmRollback(ts, ia, NULL); } else { - /*@-compmempass@*/ /* FIX: ia->relocations[0].newPath undefined */ + /*@-compdef -compmempass@*/ /* FIX: ia->relocations[0].newPath undefined */ ec += rpmInstall(ts, ia, (const char **)poptGetArgs(optCon)); - /*@=compmempass@*/ + /*@=compdef =compmempass@*/ } break; -- 2.7.4