summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-06-26 12:31:57 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-06-26 12:31:57 +0300
commitedbc9ead961fcbeb1733b47405041b653b521bcb (patch)
treeae8895429ad08b754b55545456622070c9cbd3a2 /build
parent8c5437b37914bd098a9f13366e53aba5a1c9cf15 (diff)
downloadlibrpm-tizen-edbc9ead961fcbeb1733b47405041b653b521bcb.tar.gz
librpm-tizen-edbc9ead961fcbeb1733b47405041b653b521bcb.tar.bz2
librpm-tizen-edbc9ead961fcbeb1733b47405041b653b521bcb.zip
Base64-encode %policy files to ensure it can be presented as strings
- RPMTAG_POLICIES is a string array but there's no guarantee that something marked %policy is a plaintext file that can be represented as \0-terminated string, base64-encoding them fixes that. Baby steps towards making %policy remotely usable, related to RhBug:505066. - Also remove unnecessary failure code setting, processMetadataFile() assumes failure already, and dont try to insert NULL strings in case b64encode() or pgpArmorWrap() fails
Diffstat (limited to 'build')
-rw-r--r--build/files.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/build/files.c b/build/files.c
index dfbd6757f..f0c62811a 100644
--- a/build/files.c
+++ b/build/files.c
@@ -18,6 +18,7 @@
#include <rpm/rpmlog.h>
#include "rpmio/rpmio_internal.h" /* XXX rpmioSlurp */
+#include "rpmio/base64.h"
#include "rpmio/fts.h"
#include "lib/cpio.h"
#include "lib/rpmfi_internal.h" /* XXX fi->apath */
@@ -1616,12 +1617,10 @@ static rpmRC processMetadataFile(Package pkg, FileList fl,
break;
case RPMTAG_PUBKEYS: {
if ((xx = pgpReadPkts(fn, &pkt, (size_t *)&pktlen)) <= 0) {
- rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("%s: public key read failed.\n"), fn);
goto exit;
}
if (xx != PGPARMOR_PUBKEY) {
- rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("%s: not an armored public key.\n"), fn);
goto exit;
}
@@ -1630,18 +1629,21 @@ static rpmRC processMetadataFile(Package pkg, FileList fl,
}
case RPMTAG_POLICIES:
if ((xx = rpmioSlurp(fn, &pkt, &pktlen)) != 0 || pkt == NULL) {
- rc = RPMRC_FAIL;
- rpmlog(RPMLOG_ERR, _("%s: *.te policy read failed.\n"), fn);
+ rpmlog(RPMLOG_ERR, _("%s: policy file read failed.\n"), fn);
goto exit;
}
- apkt = (char *) pkt; /* XXX unsigned char */
- pkt = NULL;
+ apkt = b64encode(pkt, pktlen, -1);
break;
}
- headerPutString(pkg->header, tag, apkt);
+ if (!apkt) {
+ rpmlog(RPMLOG_ERR, _("%s: failed to encode\n"), fn);
+ goto exit;
+ }
+ headerPutString(pkg->header, tag, apkt);
rc = RPMRC_OK;
+
if (absolute)
rc = addFile(fl, fn, NULL);