summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/header.c4
-rw-r--r--lib/psm.c9
-rw-r--r--lib/rpmlib.h6
-rw-r--r--lib/transaction.c4
-rw-r--r--rpmdb/db3.c4
-rw-r--r--rpmdb/rpmdb.c9
6 files changed, 29 insertions, 7 deletions
diff --git a/lib/header.c b/lib/header.c
index aa5bba485..6d3a2f6e1 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -1590,7 +1590,11 @@ int headerAddI18NString(Header h, int_32 tag, const char * string, const char *
entry->data = xrealloc(entry->data, entry->length + length);
memset(((char *)entry->data) + entry->length, '\0', ghosts);
+#if 0
strcpy(((char *)entry->data) + entry->length + ghosts, string);
+#else
+ memmove(((char *)entry->data) + entry->length + ghosts, string, strlen(string)+1);
+#endif
entry->length += length;
entry->info.count = langNum + 1;
diff --git a/lib/psm.c b/lib/psm.c
index f44d9b1fc..9b42d9021 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -23,12 +23,15 @@
/*@access FSM_t @*/ /* compared with NULL */
/*@access PSM_t @*/ /* compared with NULL */
/*@access FD_t @*/ /* compared with NULL */
+/*@access rpmdb @*/ /* compared with NULL */
/*@-redecl@*/
extern int _fsm_debug;
/*@=redecl@*/
+/*@-redecl -declundef -exportheadervar@*/
extern const char * chroot_prefix;
+/*@=redecl =declundef =exportheadervar@*/
int rpmVersionCompare(Header first, Header second)
{
@@ -1857,8 +1860,10 @@ assert(psm->mi == NULL);
rc = chroot(ts->rootDir);
/*@=unrecog@*/
psm->chrootDone = ts->chrootDone = 1;
- if (ts->rpmdb) ts->rpmdb->db_chrootDone = 1;
+ if (ts->rpmdb != NULL) ts->rpmdb->db_chrootDone = 1;
+ /*@-onlytrans@*/
chroot_prefix = ts->rootDir;
+ /*@=onlytrans@*/
}
break;
case PSM_CHROOT_OUT:
@@ -1868,7 +1873,7 @@ assert(psm->mi == NULL);
rc = chroot(".");
/*@=unrecog@*/
psm->chrootDone = ts->chrootDone = 0;
- if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0;
+ if (ts->rpmdb != NULL) ts->rpmdb->db_chrootDone = 0;
chroot_prefix = NULL;
(void) chdir(ts->currDir);
}
diff --git a/lib/rpmlib.h b/lib/rpmlib.h
index 7d8cc8d94..2defdc59c 100644
--- a/lib/rpmlib.h
+++ b/lib/rpmlib.h
@@ -706,7 +706,7 @@ int rpmdbOpenAll (/*@null@*/ rpmdb db)
* @param name rpm package name
* @return number of instances
*/
-int rpmdbCountPackages(rpmdb db, const char * name)
+int rpmdbCountPackages(/*@null@*/ rpmdb db, const char * name)
/*@modifies db @*/;
/** \ingroup rpmdb
@@ -876,7 +876,7 @@ int rpmdbSetIteratorModified(/*@null@*/ rpmdbMatchIterator mi, int modified)
* @param h header
* @return 0 on success
*/
-int rpmdbAdd(rpmdb db, int iid, Header h)
+int rpmdbAdd(/*@null@*/ rpmdb db, int iid, Header h)
/*@modifies db, h, fileSystem @*/;
/** \ingroup rpmdb
@@ -886,7 +886,7 @@ int rpmdbAdd(rpmdb db, int iid, Header h)
* @param offset location in Packages dbi
* @return 0 on success
*/
-int rpmdbRemove(rpmdb db, /*@unused@*/ int rid, unsigned int offset)
+int rpmdbRemove(/*@null@*/ rpmdb db, /*@unused@*/ int rid, unsigned int offset)
/*@modifies db, fileSystem @*/;
/** \ingroup rpmdb
diff --git a/lib/transaction.c b/lib/transaction.c
index d655351e6..4c2d56629 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -14,7 +14,9 @@
#include "misc.h" /* XXX stripTrailingChar, splitString, currentDirectory */
#include "rpmdb.h"
+/*@-redecl -exportheadervar@*/
extern const char * chroot_prefix;
+/*@=redecl =exportheadervar@*/
/* XXX FIXME: merge with existing (broken?) tests in system.h */
/* portability fiddles */
@@ -1770,7 +1772,9 @@ int rpmRunTransactions( rpmTransactionSet ts,
/*@-unrecog@*/ chroot(ts->rootDir); /*@=unrecog@*/
ts->chrootDone = 1;
if (ts->rpmdb) ts->rpmdb->db_chrootDone = 1;
+ /*@-onlytrans@*/
chroot_prefix = ts->rootDir;
+ /*@=onlytrans@*/
}
ht = htCreate(totalFileCount * 2, 0, 0, fpHashFunction, fpEqual);
diff --git a/rpmdb/db3.c b/rpmdb/db3.c
index bcd479cec..1ba3da9e7 100644
--- a/rpmdb/db3.c
+++ b/rpmdb/db3.c
@@ -570,7 +570,7 @@ static int db3byteswapped(dbiIndex dbi) /*@*/
if (db != NULL) {
#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3 && DB_VERSION_PATCH == 11
- int isswapped;
+ int isswapped = 0;
rc = db->get_byteswapped(db, &isswapped);
if (rc == 0)
rc = isswapped;
@@ -1050,7 +1050,7 @@ static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
if (rc == 0 && dbi->dbi_type == DB_UNKNOWN) {
#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3 && DB_VERSION_PATCH == 11
- DBTYPE dbi_type;
+ DBTYPE dbi_type = DB_UNKNOWN;
xx = db->get_type(db, &dbi_type);
if (xx == 0)
dbi->dbi_type = dbi_type;
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index adb4d05cb..d13fc79dc 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -1181,6 +1181,9 @@ int rpmdbCountPackages(rpmdb db, const char * name)
int rc = -1;
int xx;
+ if (db == NULL)
+ return 0;
+
/* XXX
* There's a segfault here with CDB access, let's treat the symptom
* while diagnosing the disease.
@@ -2234,6 +2237,9 @@ int rpmdbRemove(rpmdb rpmdb, /*@unused@*/ int rid, unsigned int hdrNum)
Header h;
sigset_t signalMask;
+ if (rpmdb == NULL)
+ return 0;
+
{ rpmdbMatchIterator mi;
mi = rpmdbInitIterator(rpmdb, RPMDBI_PACKAGES, &hdrNum, sizeof(hdrNum));
h = rpmdbNextIterator(mi);
@@ -2448,6 +2454,9 @@ int rpmdbAdd(rpmdb rpmdb, int iid, Header h)
int rc = 0;
int xx;
+ if (rpmdb == NULL)
+ return 0;
+
if (iid != 0 && iid != -1) {
int_32 tid = iid;
(void) headerRemoveEntry(h, RPMTAG_REMOVETID);