summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/header.c10
-rw-r--r--lib/header.h5
-rw-r--r--lib/package.c23
-rw-r--r--lib/rpmchecksig.c8
-rw-r--r--lib/signature.c9
5 files changed, 23 insertions, 32 deletions
diff --git a/lib/header.c b/lib/header.c
index afb9141f5..0d914de06 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -20,7 +20,7 @@ int _hdr_debug = 0;
/** \ingroup header
*/
-static unsigned char const header_magic[8] = {
+const unsigned char rpm_header_magic[8] = {
0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
};
@@ -235,7 +235,7 @@ unsigned headerSizeof(Header h, enum hMagic magicp)
switch (magicp) {
case HEADER_MAGIC_YES:
- size += sizeof(header_magic);
+ size += sizeof(rpm_header_magic);
break;
case HEADER_MAGIC_NO:
break;
@@ -1053,7 +1053,7 @@ Header headerRead(FD_t fd, enum hMagic magicp)
if (magicp == HEADER_MAGIC_YES) {
magic = block[i++];
- if (memcmp(&magic, header_magic, sizeof(magic)))
+ if (memcmp(&magic, rpm_header_magic, sizeof(magic)))
goto exit;
reserved = block[i++];
}
@@ -1101,8 +1101,8 @@ int headerWrite(FD_t fd, Header h, enum hMagic magicp)
return 1;
switch (magicp) {
case HEADER_MAGIC_YES:
- nb = Fwrite(header_magic, sizeof(char), sizeof(header_magic), fd);
- if (nb != sizeof(header_magic))
+ nb = Fwrite(rpm_header_magic, sizeof(uint8_t), sizeof(rpm_header_magic), fd);
+ if (nb != sizeof(rpm_header_magic))
goto exit;
break;
case HEADER_MAGIC_NO:
diff --git a/lib/header.h b/lib/header.h
index aa93e2291..4f06c8f5f 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -21,6 +21,11 @@
extern "C" {
#endif
+/** \ingroup header
+ * Header magic value
+ */
+extern const unsigned char rpm_header_magic[8];
+
/** \ingroup header
* Include calculation for 8 bytes of (magic, 0)?
*/
diff --git a/lib/package.c b/lib/package.c
index d3a093b36..15e94699f 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -27,11 +27,6 @@ static unsigned int nkeyids = 0;
static unsigned int nextkeyid = 0;
static unsigned int * keyids;
-/* XXX FIXME: these are doubled here and header.c and .. */
-static unsigned char const header_magic[8] = {
- 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
-};
-
void headerMergeLegacySigs(Header h, const Header sigh)
{
HeaderIterator hi;
@@ -417,8 +412,8 @@ verifyinfo_exit:
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrmd5ctx = rpmDigestInit(dig->signature.hash_algo, RPMDIGEST_NONE);
- b = (unsigned char *) header_magic;
- nb = sizeof(header_magic);
+ b = (unsigned char *) rpm_header_magic;
+ nb = sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrmd5ctx, b, nb);
dig->nbytes += nb;
@@ -458,8 +453,8 @@ verifyinfo_exit:
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrsha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- b = (unsigned char *) header_magic;
- nb = sizeof(header_magic);
+ b = (unsigned char *) rpm_header_magic;
+ nb = sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrsha1ctx, b, nb);
dig->nbytes += nb;
@@ -524,7 +519,7 @@ rpmRC rpmReadHeader(rpmts ts, FD_t fd, Header *hdrp, char ** msg)
_("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
goto exit;
}
- if (memcmp(block, header_magic, sizeof(header_magic))) {
+ if (memcmp(block, rpm_header_magic, sizeof(rpm_header_magic))) {
rasprintf(&buf, _("hdr magic: BAD\n"));
goto exit;
}
@@ -736,8 +731,8 @@ rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
break;
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrmd5ctx = rpmDigestInit(dig->signature.hash_algo, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrmd5ctx, header_magic, sizeof(header_magic));
- dig->nbytes += sizeof(header_magic);
+ (void) rpmDigestUpdate(dig->hdrmd5ctx, rpm_header_magic, sizeof(rpm_header_magic));
+ dig->nbytes += sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrmd5ctx, utd.data, utd.count);
dig->nbytes += utd.count;
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DIGEST), dig->nbytes);
@@ -761,8 +756,8 @@ rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
break;
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrsha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrsha1ctx, header_magic, sizeof(header_magic));
- dig->nbytes += sizeof(header_magic);
+ (void) rpmDigestUpdate(dig->hdrsha1ctx, rpm_header_magic, sizeof(rpm_header_magic));
+ dig->nbytes += sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrsha1ctx, utd.data, utd.count);
dig->nbytes += utd.count;
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DIGEST), dig->nbytes);
diff --git a/lib/rpmchecksig.c b/lib/rpmchecksig.c
index 7e8131e22..f80222d82 100644
--- a/lib/rpmchecksig.c
+++ b/lib/rpmchecksig.c
@@ -460,10 +460,6 @@ rpmtsClean(ts);
return res;
}
-static unsigned char const header_magic[8] = {
- 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
-};
-
/**
* @todo If the GPG key was known available, the md5 digest could be skipped.
*/
@@ -495,10 +491,10 @@ static int readFile(FD_t fd, const char * fn, pgpDig dig)
goto exit;
}
dig->hdrsha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrsha1ctx, header_magic, sizeof(header_magic));
+ (void) rpmDigestUpdate(dig->hdrsha1ctx, rpm_header_magic, sizeof(rpm_header_magic));
(void) rpmDigestUpdate(dig->hdrsha1ctx, utd.data, utd.count);
dig->hdrmd5ctx = rpmDigestInit(dig->signature.hash_algo, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrmd5ctx, header_magic, sizeof(header_magic));
+ (void) rpmDigestUpdate(dig->hdrmd5ctx, rpm_header_magic, sizeof(rpm_header_magic));
(void) rpmDigestUpdate(dig->hdrmd5ctx, utd.data, utd.count);
rpmtdFreeData(&utd);
}
diff --git a/lib/signature.c b/lib/signature.c
index 67f70ab6b..feafc5eaa 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -138,11 +138,6 @@ static inline rpmRC printSize(FD_t fd, size_t siglen, size_t pad, rpm_loff_t dat
return RPMRC_OK;
}
-/* XXX sigh yet another duplicate.. */
-static unsigned char const header_magic[8] = {
- 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
-};
-
rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg)
{
char *buf = NULL;
@@ -174,7 +169,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg)
(int)sizeof(block), xx);
goto exit;
}
- if (memcmp(block, header_magic, sizeof(header_magic))) {
+ if (memcmp(block, rpm_header_magic, sizeof(rpm_header_magic))) {
rasprintf(&buf, _("sigh magic: BAD\n"));
goto exit;
}
@@ -698,7 +693,7 @@ static int makeHDRSignature(Header sigh, const char * file, rpmSigTag sigTag,
goto exit;
}
ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(ctx, header_magic, sizeof(header_magic));
+ (void) rpmDigestUpdate(ctx, rpm_header_magic, sizeof(rpm_header_magic));
(void) rpmDigestUpdate(ctx, utd.data, utd.count);
(void) rpmDigestFinal(ctx, (void **)&SHA1, NULL, 1);
rpmtdFreeData(&utd);