From: Panu Matilainen Date: Fri, 4 Nov 2011 10:24:32 +0000 (+0200) Subject: Added sanity checks on pgpPrtPkts() entry X-Git-Tag: tznext/4.11.0.1.tizen20130304~836 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=03b3d699c3b84c3088df23f4e961f6d9a597f7e4;p=tools%2Flibrpm-tizen.git Added sanity checks on pgpPrtPkts() entry - Error out cleanly on NULL pkts pointer (caller error but not worth dying for) - Error out early if packet is clearly not valid --- diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c index 1765110..2be3154 100644 --- a/rpmio/rpmpgp.c +++ b/rpmio/rpmpgp.c @@ -1135,14 +1135,17 @@ pgpDig pgpFreeDig(pgpDig dig) int pgpPrtPkts(const uint8_t * pkts, size_t pktlen, pgpDig dig, int printing) { - unsigned int val = *pkts; + unsigned int val = (pkts != NULL) ? *pkts : 0; const uint8_t *p; size_t pleft; int len; pgpDigParams _digp = NULL; + if (!(val & 0x80)) + return -1; + _print = printing; - if (dig != NULL && (val & 0x80)) { + if (dig != NULL) { pgpTag tag = (val & 0x40) ? (val & 0x3f) : ((val >> 2) & 0xf); _digp = (tag == PGPTAG_SIGNATURE) ? &dig->signature : &dig->pubkey; _digp->tag = tag;