summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2016-11-22 09:29:32 +0200
committerPanu Matilainen <pmatilai@redhat.com>2016-11-22 10:19:24 +0200
commit0823ad375f639d9df2aa93c8a73e9bb74f0e7c94 (patch)
tree5ad2fc0071c2676266fc8f4e945d05b4db03a659
parent9febd5141d7f1383d8335a26efe21222e9934a27 (diff)
downloadrpm-0823ad375f639d9df2aa93c8a73e9bb74f0e7c94.tar.gz
Refactor hdrblobInit() to call headerVerifyInfo() by itself
Having callers call verification in separate steps is just absurd, this is where it belongs. Rename headerVerifyInfo() to hdrblobVerifyInfo() and make static to properly bury it inside header.c.
-rw-r--r--lib/header.c6
-rw-r--r--lib/header_internal.h9
-rw-r--r--lib/package.c7
-rw-r--r--lib/signature.c4
4 files changed, 7 insertions, 19 deletions
diff --git a/lib/header.c b/lib/header.c
index 9adf52133..34d42e036 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -206,7 +206,7 @@ Header headerNew(void)
return headerCreate(NULL, 0, 0);
}
-int headerVerifyInfo(hdrblob blob, char **emsg)
+static rpmRC hdrblobVerifyInfo(hdrblob blob, char **emsg)
{
struct entryInfo_s info;
int i, len = 0;
@@ -1919,6 +1919,10 @@ rpmRC hdrblobInit(const void *uh, size_t uc,
if (hdrblobVerifyRegion(regionTag, exact_size, blob, emsg) == RPMRC_FAIL)
goto exit;
+ /* Sanity check the rest of the header structure. */
+ if (hdrblobVerifyInfo(blob, emsg))
+ goto exit;
+
rc = RPMRC_OK;
exit:
diff --git a/lib/header_internal.h b/lib/header_internal.h
index 57d6c1dce..c59064bee 100644
--- a/lib/header_internal.h
+++ b/lib/header_internal.h
@@ -86,15 +86,6 @@ rpmRC hdrblobInit(const void *uh, size_t uc,
struct hdrblob_s *blob, char **emsg);
/** \ingroup header
- * Perform simple sanity and range checks on header tag(s).
- * @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(hdrblob blob, char **emsg);
-
-/** \ingroup header
* Set header instance (rpmdb record number)
* @param h header
* @param instance record number
diff --git a/lib/package.c b/lib/package.c
index da8a48502..66588531b 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -237,13 +237,10 @@ static rpmRC headerVerify(rpmKeyring keyring, rpmVSFlags vsflags,
hdrblob blob, char ** msg)
{
char *buf = NULL;
- rpmRC rc = RPMRC_FAIL; /* assume failure */
-
- /* Sanity check the rest of the header structure. */
- rc = headerVerifyInfo(blob, &buf);
+ rpmRC rc = RPMRC_NOTFOUND; /* assume not found */
/* Verify header-only digest/signature if there is one we can use. */
- if (rc == RPMRC_OK && blob->il > blob->ril) {
+ if (blob->il > blob->ril) {
rc = headerSigVerify(keyring, vsflags,
blob->il, blob->dl, blob->ril, blob->rdl,
blob->pe, blob->dataStart, &buf);
diff --git a/lib/signature.c b/lib/signature.c
index 6a373609d..7a1dcda50 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -200,10 +200,6 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, char ** msg)
if (hdrblobInit(ei, uc, RPMTAG_HEADERSIGNATURES, 1, &blob, &buf) != RPMRC_OK)
goto exit;
- /* Sanity check signature tags */
- if (headerVerifyInfo(&blob, &buf))
- goto exit;
-
/* OK, blob looks sane, load the header. */
sigh = headerImport(blob.ei, blob.uc, 0);
if (sigh == NULL) {