From 6e59d413a2c49ecf4e14fef555b1ba344d744dd7 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Mon, 23 Nov 2015 14:03:04 +0100 Subject: [PATCH] asn1helpers.c: Fix asn1bitstr_to_u32 function The value in buf is kept in host byte order so no need to swap it around. --- src/asn1helpers.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/asn1helpers.c b/src/asn1helpers.c index 3225223d..2a1b187a 100644 --- a/src/asn1helpers.c +++ b/src/asn1helpers.c @@ -67,13 +67,11 @@ uint8_t asn1str_to_u8(const OCTET_STRING_t *in) uint32_t asn1bitstr_to_u32(const BIT_STRING_t *in) { uint32_t ret = 0; - int i; - for (i = 0; i < 4; i++) { - if (in->size < i) - break; - ret <<= 8; - ret |= in->buf[i]; - } + if (in->size < 4) + return 0; + + ret = *(uint32_t *)in->buf; + return ret; }