chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
45afda
From 492823ca53f5666b82e94fcfdd422bdcd67005cb Mon Sep 17 00:00:00 2001
45afda
From: Panu Matilainen <pmatilai@redhat.com>
45afda
Date: Tue, 10 Oct 2017 11:07:38 +0300
45afda
Subject: [PATCH 03/33] Use lower-level headerPut() for file signing
45afda
45afda
Not supposed to affect behavior at all, but we'll need this in the
45afda
next step.
45afda
---
45afda
 sign/rpmsignfiles.c | 19 ++++++++++++++++---
45afda
 1 file changed, 16 insertions(+), 3 deletions(-)
45afda
45afda
diff --git a/sign/rpmsignfiles.c b/sign/rpmsignfiles.c
45afda
index 61b73bd40..1fc127cb1 100644
45afda
--- a/sign/rpmsignfiles.c
45afda
+++ b/sign/rpmsignfiles.c
45afda
@@ -82,7 +82,7 @@ char *keypass)
45afda
 
45afda
 rpmRC rpmSignFiles(Header h, const char *key, char *keypass)
45afda
 {
45afda
-    struct rpmtd_s digests;
45afda
+    struct rpmtd_s digests, td;
45afda
     int algo;
45afda
     int diglen;
45afda
     uint32_t siglen;
45afda
@@ -110,7 +110,19 @@ rpmRC rpmSignFiles(Header h, const char *key, char *keypass)
45afda
     headerDel(h, RPMTAG_FILESIGNATURELENGTH);
45afda
     headerDel(h, RPMTAG_FILESIGNATURES);
45afda
     siglen = signatureLength(algoname, diglen, key, keypass);
45afda
-    headerPutUint32(h, RPMTAG_FILESIGNATURELENGTH, &siglen, 1);
45afda
+
45afda
+    rpmtdReset(&td);
45afda
+    td.tag = RPMTAG_FILESIGNATURELENGTH;
45afda
+    td.type = RPM_INT32_TYPE;
45afda
+    td.data = &siglen;
45afda
+    td.count = 1;
45afda
+    headerPut(h, &td, HEADERPUT_DEFAULT);
45afda
+
45afda
+    rpmtdReset(&td);
45afda
+    td.tag = RPMTAG_FILESIGNATURES;
45afda
+    td.type = RPM_STRING_ARRAY_TYPE;
45afda
+    td.data = NULL; /* set in the loop below */
45afda
+    td.count = 1;
45afda
 
45afda
     headerGet(h, RPMTAG_FILEDIGESTS, &digests, HEADERGET_MINMEM);
45afda
     while ((digest = rpmtdNextString(&digests))) {
45afda
@@ -120,7 +132,8 @@ rpmRC rpmSignFiles(Header h, const char *key, char *keypass)
45afda
 	    rc = RPMRC_FAIL;
45afda
 	    goto exit;
45afda
 	}
45afda
-	if (!headerPutString(h, RPMTAG_FILESIGNATURES, signature)) {
45afda
+	td.data = &signature;
45afda
+	if (!headerPut(h, &td, HEADERPUT_APPEND)) {
45afda
 	    free(signature);
45afda
 	    rpmlog(RPMLOG_ERR, _("headerPutString failed\n"));
45afda
 	    rc = RPMRC_FAIL;
45afda
-- 
45afda
2.27.0
45afda