X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=decodekey.c;h=0ff0625929849713a2597bf36769f009badab90c;hp=522ad901383dd6a217b0ef5ed2320a93e3d51f8b;hb=adc800dbc424a1e246dd4a82a0c2e88eeda25531;hpb=ec38d8bd7e8a66645e75e3d6c8b9dadb5dd85ec7 diff --git a/decodekey.c b/decodekey.c index 522ad90..0ff0625 100644 --- a/decodekey.c +++ b/decodekey.c @@ -13,11 +13,10 @@ * more details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * this program. If not, see . */ -#include +#include #include #include #include @@ -28,7 +27,6 @@ #include "keyid.h" #include "keystructs.h" #include "ll.h" -#include "log.h" #include "openpgp.h" /* @@ -51,7 +49,7 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, int length = 0; int packetlen = 0; - log_assert(data != NULL); + assert(data != NULL); /* Make sure we actually have the 2 byte length field */ if (len < 2) { @@ -82,6 +80,10 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, packetlen <<= 8; packetlen |= data[offset++]; } + /* Check the supplied length is within the remaining data */ + if (packetlen == 0 || (packetlen + offset) > length) { + return ONAK_E_INVALID_PKT; + } switch (data[offset] & 0x7F) { case OPENPGP_SIGSUB_CREATION: /* @@ -158,11 +160,8 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, * 7 is set in which case we log a major error. */ if (data[offset] & 0x80) { - logthing(LOGTHING_CRITICAL, - "Critical subpacket type not parsed: 0x%X", - data[offset]); + return ONAK_E_UNSUPPORTED_FEATURE; } - } offset += packetlen; } @@ -170,28 +169,6 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, return ONAK_E_OK; } -/** - * keysigs - Return the sigs on a given OpenPGP signature list. - * @curll: The current linked list. Can be NULL to create a new list. - * @sigs: The signature list we want the sigs on. - * - * Returns a linked list of stats_key elements containing the sigs on the - * supplied OpenPGP packet list. - */ -struct ll *keysigs(struct ll *curll, - struct openpgp_packet_list *sigs) -{ - uint64_t keyid = 0; - - while (sigs != NULL) { - keyid = sig_keyid(sigs->packet); - sigs = sigs->next; - curll = lladd(curll, createandaddtohash(keyid)); - } - - return curll; -} - /** * sig_info - Get info on a given OpenPGP signature packet * @packet: The signature packet