summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorewt <devnull@localhost>1997-01-29 17:39:46 +0000
committerewt <devnull@localhost>1997-01-29 17:39:46 +0000
commitbe0b90359bcd8156385178eb9b570c0538c0333f (patch)
tree3466cf2ea6723f556cfe12177c0fe806305f7556 /lib
parent364db20c195b8e5fd06cc27e6745dc8ba1e583f9 (diff)
downloadrpm-be0b90359bcd8156385178eb9b570c0538c0333f.tar.gz
rpm-be0b90359bcd8156385178eb9b570c0538c0333f.tar.bz2
rpm-be0b90359bcd8156385178eb9b570c0538c0333f.zip
does some basic sanity checks on headers read from the database
CVS patchset: 1375 CVS date: 1997/01/29 17:39:46
Diffstat (limited to 'lib')
-rw-r--r--lib/rebuilddb.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/rebuilddb.c b/lib/rebuilddb.c
index 78c9e68a9..e359141b8 100644
--- a/lib/rebuilddb.c
+++ b/lib/rebuilddb.c
@@ -18,7 +18,7 @@
int rpmdbRebuild(char * rootdir) {
rpmdb olddb, newdb;
char * dbpath, * newdbpath;
- unsigned int recnum;
+ int recnum;
Header h;
int failed = 0;
@@ -57,17 +57,28 @@ int rpmdbRebuild(char * rootdir) {
}
recnum = rpmdbFirstRecNum(olddb);
- while (recnum) {
+ while (recnum > 0) {
if (!(h = rpmdbGetRecord(olddb, recnum))) {
rpmError(RPMERR_INTERNAL, "cannot read database record at %d", recnum);
failed = 1;
break;
}
- if (rpmdbAdd(newdb, h)) {
- rpmError(RPMERR_INTERNAL, "cannot add record originally at %d",
- recnum);
- failed = 1;
- break;
+
+ /* let's sanity check this record a bit, otherwise just skip it */
+ if (headerIsEntry(h, RPMTAG_NAME) &&
+ headerIsEntry(h, RPMTAG_VERSION) &&
+ headerIsEntry(h, RPMTAG_RELEASE) &&
+ headerIsEntry(h, RPMTAG_RELEASE) &&
+ headerIsEntry(h, RPMTAG_BUILDTIME)) {
+ if (rpmdbAdd(newdb, h)) {
+ rpmError(RPMERR_INTERNAL, "cannot add record originally at %d",
+ recnum);
+ failed = 1;
+ break;
+ }
+ } else {
+ rpmError(RPMERR_INTERNAL, "record number %d in database is bad "
+ "-- skipping it", recnum);
}
recnum = rpmdbNextRecNum(olddb, recnum);
}