summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/header.c14
-rw-r--r--lib/header_internal.h10
-rw-r--r--lib/package.c3
-rw-r--r--lib/signature.c3
4 files changed, 11 insertions, 19 deletions
diff --git a/lib/header.c b/lib/header.c
index e61524fd1..b8c1bffec 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -206,14 +206,14 @@ Header headerNew(void)
return headerCreate(NULL, 0, 0);
}
-int headerVerifyInfo(int il, int dl,
- const struct entryInfo_s * pe, const void *dataStart,
- char **emsg)
+int headerVerifyInfo(hdrblob blob, char **emsg)
{
struct entryInfo_s info;
int i, len = 0;
int32_t end = 0;
- const char *ds = dataStart;
+ const char *ds = (const char *) blob->dataStart;
+ int32_t il = (blob->regionTag) ? blob->il-1 : blob->il;
+ entryInfo pe = (blob->regionTag) ? blob->pe+1 : blob->pe;
for (i = 0; i < il; i++) {
ei2h(&pe[i], &info);
@@ -226,14 +226,14 @@ int headerVerifyInfo(int il, int dl,
goto err;
if (hdrchkAlign(info.type, info.offset))
goto err;
- if (hdrchkRange(dl, info.offset))
+ if (hdrchkRange(blob->dl, info.offset))
goto err;
/* Verify the data actually fits */
len = dataLength(info.type, ds + info.offset,
- info.count, 1, ds + dl);
+ info.count, 1, ds + blob->dl);
end = info.offset + len;
- if (hdrchkRange(dl, end) || len <= 0)
+ if (hdrchkRange(blob->dl, end) || len <= 0)
goto err;
}
return 0; /* Everything ok */
diff --git a/lib/header_internal.h b/lib/header_internal.h
index 2729c345f..962bf15e3 100644
--- a/lib/header_internal.h
+++ b/lib/header_internal.h
@@ -90,18 +90,12 @@ rpmRC headerVerifyRegion(rpmTagVal regionTag, int exact_size,
/** \ingroup header
* Perform simple sanity and range checks on header tag(s).
- * @param il no. of tags in header
- * @param dl no. of bytes in header data.
- * @param pe 1st element in tag array, big-endian
- * @param dataStart start of data area
+ * @param blob header blob
* @retvar emsg possible error message (malloced) or NULL to disable
* @return 0 on success, otherwise ordinal of failed tag
*/
RPM_GNUC_INTERNAL
-int headerVerifyInfo(int il, int dl,
- const struct entryInfo_s * pe, const void *dataStart,
- char **emsg);
-
+int headerVerifyInfo(hdrblob blob, char **emsg);
/** \ingroup header
* Set header instance (rpmdb record number)
diff --git a/lib/package.c b/lib/package.c
index bc88327d8..0e349f9ff 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -333,8 +333,7 @@ static rpmRC headerVerify(rpmKeyring keyring, rpmVSFlags vsflags,
/* Sanity check the rest of the header structure. */
if (rc != RPMRC_FAIL) {
- int region = (rc == RPMRC_OK) ? 1 : 0;
- if (headerVerifyInfo(blob->il-region, blob->dl, blob->pe+region, blob->dataStart, &buf))
+ if (headerVerifyInfo(blob, &buf))
rc = RPMRC_FAIL;
}
diff --git a/lib/signature.c b/lib/signature.c
index 623e5097b..cc658a46f 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -204,8 +204,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, char ** msg)
xx = headerVerifyRegion(RPMTAG_HEADERSIGNATURES, 1, &blob, &buf);
/* Sanity check signature tags */
if (xx != RPMRC_FAIL) {
- int region = (xx == RPMRC_OK) ? 1 : 0;
- if (headerVerifyInfo(blob.il-region, blob.dl, blob.pe+region, blob.dataStart, &buf))
+ if (headerVerifyInfo(&blob, &buf))
xx = RPMRC_FAIL;
}