diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | build/files.c | 2 | ||||
-rw-r--r-- | build/policies.c | 4 | ||||
-rw-r--r-- | lib/formats.c | 4 | ||||
-rw-r--r-- | lib/rpmts.c | 2 | ||||
-rw-r--r-- | plugins/sepolicy.c | 4 | ||||
-rw-r--r-- | preinstall.am | 4 | ||||
-rw-r--r-- | rpmio/Makefile.am | 2 | ||||
-rw-r--r-- | rpmio/base64.c | 14 | ||||
-rw-r--r-- | rpmio/digest.h | 1 | ||||
-rw-r--r-- | rpmio/rpmbase64.h (renamed from rpmio/base64.h) | 6 | ||||
-rw-r--r-- | rpmio/rpmkeyring.c | 4 | ||||
-rw-r--r-- | rpmio/rpmlua.c | 14 | ||||
-rw-r--r-- | rpmio/rpmpgp.c | 10 |
14 files changed, 38 insertions, 34 deletions
diff --git a/Makefile.am b/Makefile.am index b1568a6d1..179c3e99c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,6 +62,7 @@ pkginclude_HEADERS += rpmio/rpmsw.h pkginclude_HEADERS += rpmio/rpmfileutil.h pkginclude_HEADERS += rpmio/rpmutil.h pkginclude_HEADERS += rpmio/rpmkeyring.h +pkginclude_HEADERS += rpmio/rpmbase64.h pkginclude_HEADERS += lib/header.h pkginclude_HEADERS += lib/rpmdb.h diff --git a/build/files.c b/build/files.c index aeceed80d..f222a5dfa 100644 --- a/build/files.c +++ b/build/files.c @@ -19,9 +19,9 @@ #include <rpm/rpmfc.h> #include <rpm/rpmfileutil.h> /* rpmDoDigest() */ #include <rpm/rpmlog.h> +#include <rpm/rpmbase64.h> #include "rpmio/rpmio_internal.h" /* XXX rpmioSlurp */ -#include "rpmio/base64.h" #include "misc/fts.h" #include "lib/cpio.h" #include "lib/rpmfi_internal.h" /* XXX fi->apath */ diff --git a/build/policies.c b/build/policies.c index 8316637c3..d3b19302a 100644 --- a/build/policies.c +++ b/build/policies.c @@ -9,10 +9,10 @@ #include <rpm/argv.h> #include <rpm/rpmlog.h> #include <rpm/rpmpol.h> +#include <rpm/rpmbase64.h> #include "rpmio/rpmio_internal.h" #include "build/rpmbuild_internal.h" -#include "rpmio/base64.h" #include "debug.h" @@ -165,7 +165,7 @@ static ModuleRec newModule(const char *path, const char *name, goto err; } - mod->data = b64encode(raw, rawlen, -1); + mod->data = rpmBase64Encode(raw, rawlen, -1); if (!mod->data) { rpmlog(RPMLOG_ERR, _("Failed to encode policy file: %s\n"), mod->path); diff --git a/lib/formats.c b/lib/formats.c index 03d32f238..6edb264bb 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -305,7 +305,7 @@ static char * armorFormat(rpmtd td) case RPM_STRING_TYPE: case RPM_STRING_ARRAY_TYPE: enc = rpmtdGetString(td); - if (b64decode(enc, (void **)&bs, &ns)) + if (rpmBase64Decode(enc, (void **)&bs, &ns)) return xstrdup(_("(not base64)")); s = bs; atype = PGPARMOR_PUBKEY; /* XXX check pkt for pubkey */ @@ -343,7 +343,7 @@ static char * base64Format(rpmtd td) if (rpmtdType(td) != RPM_BIN_TYPE) { val = xstrdup(_("(not a blob)")); } else { - val = b64encode(td->data, td->count, -1); + val = rpmBase64Encode(td->data, td->count, -1); if (val == NULL) val = xstrdup(""); } diff --git a/lib/rpmts.c b/lib/rpmts.c index 1dd38b263..1c3cd668a 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -319,7 +319,7 @@ static int loadKeyringFromDB(rpmts ts) uint8_t *pkt; size_t pktlen; - if (b64decode(key, (void **) &pkt, &pktlen) == 0) { + if (rpmBase64Decode(key, (void **) &pkt, &pktlen) == 0) { rpmPubkey key = rpmPubkeyNew(pkt, pktlen); if (rpmKeyringAddKey(ts->keyring, key) == 0) { char *nvr = headerGetAsString(h, RPMTAG_NVR); diff --git a/plugins/sepolicy.c b/plugins/sepolicy.c index a4aecc3c2..291641527 100644 --- a/plugins/sepolicy.c +++ b/plugins/sepolicy.c @@ -11,8 +11,8 @@ #include <rpm/rpmpol.h> #include <rpm/rpmfileutil.h> #include <rpm/rpmmacro.h> +#include <rpm/rpmbase64.h> -#include "rpmio/base64.h" #include "lib/rpmte_internal.h" #include "lib/rpmts_internal.h" /* rpmtsSELabelFoo() */ @@ -216,7 +216,7 @@ static rpmRC sepolWritePolicy(const sepol * pol, char **path) size_t policylen; rpmRC rc = RPMRC_FAIL; - if (b64decode(pol->data, (void **) &policy, &policylen) != 0) { + if (rpmBase64Decode(pol->data, (void **) &policy, &policylen) != 0) { rpmlog(RPMLOG_ERR, _("Failed to decode policy for %s\n"), pol->name); goto exit; diff --git a/preinstall.am b/preinstall.am index 170c94c6b..4da80c1f8 100644 --- a/preinstall.am +++ b/preinstall.am @@ -46,6 +46,10 @@ include/rpm/rpmkeyring.h: rpmio/rpmkeyring.h include/rpm/$(dirstamp) $(INSTALL_DATA) $(top_srcdir)/rpmio/rpmkeyring.h include/rpm/rpmkeyring.h BUILT_SOURCES += include/rpm/rpmkeyring.h CLEANFILES += include/rpm/rpmkeyring.h +include/rpm/rpmbase64.h: rpmio/rpmbase64.h include/rpm/$(dirstamp) + $(INSTALL_DATA) $(top_srcdir)/rpmio/rpmbase64.h include/rpm/rpmbase64.h +BUILT_SOURCES += include/rpm/rpmbase64.h +CLEANFILES += include/rpm/rpmbase64.h include/rpm/header.h: lib/header.h include/rpm/$(dirstamp) $(INSTALL_DATA) $(top_srcdir)/lib/header.h include/rpm/header.h BUILT_SOURCES += include/rpm/header.h diff --git a/rpmio/Makefile.am b/rpmio/Makefile.am index 2db6e6a2b..d699c03fb 100644 --- a/rpmio/Makefile.am +++ b/rpmio/Makefile.am @@ -10,7 +10,7 @@ AM_CPPFLAGS += -DLOCALSTATEDIR="\"$(localstatedir)\"" usrlibdir = $(libdir) usrlib_LTLIBRARIES = librpmio.la librpmio_la_SOURCES = \ - argv.c base64.h base64.c digest.h digest.c macro.c \ + argv.c base64.c digest.h digest.c macro.c \ rpmhook.c rpmio.c rpmlog.c rpmmalloc.c \ rpmpgp.c rpmsq.c rpmsw.c url.c \ rpmio_internal.h rpmhook.h \ diff --git a/rpmio/base64.c b/rpmio/base64.c index 6b006e166..60e67d442 100644 --- a/rpmio/base64.c +++ b/rpmio/base64.c @@ -4,7 +4,7 @@ #include <arpa/inet.h> #include <stdlib.h> -#include "rpmio/base64.h" +#include <rpm/rpmbase64.h> static char base64_encode_value(char value_in) @@ -58,7 +58,7 @@ static char *base64_encode_block(const char *plaintext_in, int length_in, char * #define BASE64_DEFAULT_LINE_LENGTH 64 -char *b64encode(const void *data, size_t len, int linelen) +char *rpmBase64Encode(const void *data, size_t len, int linelen) { size_t encodedlen; const char *dataptr = data; @@ -161,7 +161,7 @@ static size_t base64_decode_block(const char *code_in, const size_t length_in, c return plainchar - plaintext_out; } -int b64decode(const char *in, void **out, size_t *outlen) +int rpmBase64Decode(const char *in, void **out, size_t *outlen) { size_t outcnt = 0; const char *inptr = in; @@ -202,7 +202,7 @@ int b64decode(const char *in, void **out, size_t *outlen) #define CRC24_INIT 0xb704ce #define CRC24_POLY 0x1864cfb -char *b64crc(const unsigned char *data, size_t len) +char *rpmBase64CRC(const unsigned char *data, size_t len) { uint32_t crc = CRC24_INIT; int i; @@ -218,7 +218,7 @@ char *b64crc(const unsigned char *data, size_t len) crc = htonl(crc & 0xffffff); data = (unsigned char *)&crc; ++data; - return b64encode(data, 3, 0); + return rpmBase64Encode(data, 3, 0); } #ifdef BASE64_TEST @@ -233,9 +233,9 @@ int main(int argc, char *argv[]) size_t size; int err; printf("Original: %lu\n%s\n", sizeof(tst)-1, tst); - encoded = b64encode(tst, sizeof(tst)-1, 64); + encoded = rpmBase64Encode(tst, sizeof(tst)-1, 64); printf("Encoded: %lu\n%s\n", strlen(encoded), encoded); - if ((err = b64decode(encoded, &decoded, &size)) != 0) { + if ((err = rpmBase64Decode(encoded, &decoded, &size)) != 0) { fprintf(stderr, "Error in decode: %d\n", err); return 1; } diff --git a/rpmio/digest.h b/rpmio/digest.h index afbb32ed7..f10f1c871 100644 --- a/rpmio/digest.h +++ b/rpmio/digest.h @@ -2,7 +2,6 @@ #define _RPMDIGEST_H #include <rpm/rpmpgp.h> -#include "rpmio/base64.h" typedef struct pgpDigAlg_s * pgpDigAlg; diff --git a/rpmio/base64.h b/rpmio/rpmbase64.h index d572856f7..95ee9cd03 100644 --- a/rpmio/base64.h +++ b/rpmio/rpmbase64.h @@ -14,7 +14,7 @@ extern "C" { * the returned string is empty when len == 0 * returns NULL on failures */ -char *b64encode(const void *data, size_t len, int linelen); +char *rpmBase64Encode(const void *data, size_t len, int linelen); /* decodes from zero terminated base64 encoded string to a newly malloced buffer * ignores whitespace characters in the input string @@ -25,12 +25,12 @@ char *b64encode(const void *data, size_t len, int linelen); * 3 - invalid characters on input * 4 - malloc failed */ -int b64decode(const char *in, void **out, size_t *outlen); +int rpmBase64Decode(const char *in, void **out, size_t *outlen); /* counts CRC24 and base64 encodes it in a malloced string * returns NULL on failures */ -char *b64crc(const unsigned char *data, size_t len); +char *rpmBase64CRC(const unsigned char *data, size_t len); #ifdef __cplusplus } diff --git a/rpmio/rpmkeyring.c b/rpmio/rpmkeyring.c index 6ebaab89e..18fdfa01c 100644 --- a/rpmio/rpmkeyring.c +++ b/rpmio/rpmkeyring.c @@ -5,8 +5,8 @@ #include <rpm/rpmfileutil.h> #include <rpm/rpmlog.h> #include <rpm/rpmkeyring.h> +#include <rpm/rpmbase64.h> -#include "rpmio/base64.h" #include "rpmio/digest.h" #include "debug.h" @@ -210,7 +210,7 @@ char * rpmPubkeyBase64(rpmPubkey key) char *enc = NULL; if (key) { - enc = b64encode(key->pkt, key->pktlen, -1); + enc = rpmBase64Encode(key->pkt, key->pktlen, -1); } return enc; } diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c index fa8eed36c..441d062da 100644 --- a/rpmio/rpmlua.c +++ b/rpmio/rpmlua.c @@ -15,8 +15,8 @@ #include <rpm/rpmlog.h> #include <rpm/rpmurl.h> #include <rpm/rpmfileutil.h> +#include <rpm/rpmbase64.h> #include "rpmio/rpmhook.h" -#include "rpmio/base64.h" #define _RPMLUA_INTERNAL #include "rpmio/rpmlua.h" @@ -588,7 +588,7 @@ void rpmluaInteractive(rpmlua _lua) /* ------------------------------------------------------------------ */ /* Lua API */ -static int rpm_b64encode(lua_State *L) +static int rpm_rpmBase64Encode(lua_State *L) { const char *str = luaL_checkstring(L, 1); size_t len = lua_strlen(L, 1); @@ -596,20 +596,20 @@ static int rpm_b64encode(lua_State *L) if (lua_gettop(L) == 2) linelen = luaL_checkinteger(L, 2); if (str && len) { - char *data = b64encode(str, len, linelen); + char *data = rpmBase64Encode(str, len, linelen); lua_pushstring(L, data); free(data); } return 1; } -static int rpm_b64decode(lua_State *L) +static int rpm_rpmBase64Decode(lua_State *L) { const char *str = luaL_checkstring(L, 1); if (str) { void *data = NULL; size_t len = 0; - if (b64decode(str, &data, &len) == 0) { + if (rpmBase64Decode(str, &data, &len) == 0) { lua_pushlstring(L, data, len); } else { lua_pushnil(L); @@ -823,8 +823,8 @@ static int rpm_print (lua_State *L) } static const luaL_reg rpmlib[] = { - {"b64encode", rpm_b64encode}, - {"b64decode", rpm_b64decode}, + {"rpmBase64Encode", rpm_rpmBase64Encode}, + {"rpmBase64Decode", rpm_rpmBase64Decode}, {"expand", rpm_expand}, {"define", rpm_define}, {"register", rpm_register}, diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c index bb2ee78cc..b00542c89 100644 --- a/rpmio/rpmpgp.c +++ b/rpmio/rpmpgp.c @@ -783,7 +783,7 @@ int pgpExtractPubkeyFingerprint(const char * b64pkt, pgpKeyID_t keyid) size_t pktlen; int rc = -1; /* assume failure */ - if (b64decode(b64pkt, (void **)&pkt, &pktlen) == 0) { + if (rpmBase64Decode(b64pkt, (void **)&pkt, &pktlen) == 0) { if (pgpPubkeyFingerprint(pkt, pktlen, keyid) == 0) { /* if there ever was a bizarre return code for success... */ rc = sizeof(keyid); @@ -1175,7 +1175,7 @@ static pgpArmor decodePkts(uint8_t *b, uint8_t **pkt, size_t *pktlen) crcdec = NULL; crclen = 0; - if (b64decode(crcenc, (void **)&crcdec, &crclen) != 0) { + if (rpmBase64Decode(crcenc, (void **)&crcdec, &crclen) != 0) { ec = PGPARMOR_ERR_CRC_DECODE; goto exit; } @@ -1183,7 +1183,7 @@ static pgpArmor decodePkts(uint8_t *b, uint8_t **pkt, size_t *pktlen) crcdec = _free(crcdec); dec = NULL; declen = 0; - if (b64decode(enc, (void **)&dec, &declen) != 0) { + if (rpmBase64Decode(enc, (void **)&dec, &declen) != 0) { ec = PGPARMOR_ERR_BODY_DECODE; goto exit; } @@ -1232,8 +1232,8 @@ pgpArmor pgpParsePkts(const char *armor, uint8_t ** pkt, size_t * pktlen) char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns) { char *buf = NULL, *val = NULL; - char *enc = b64encode(s, ns, -1); - char *crc = b64crc(s, ns); + char *enc = rpmBase64Encode(s, ns, -1); + char *crc = rpmBase64CRC(s, ns); const char *valstr = pgpValStr(pgpArmorTbl, atype); if (crc != NULL && enc != NULL) { |