bio_reader: Fix read_uint24
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 2 Mar 2018 13:45:28 +0000 (14:45 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 12 Jun 2018 19:47:39 +0000 (21:47 +0200)
src/libstrongswan/bio/bio_reader.c

index 82e4050..e6b459b 100644 (file)
@@ -122,13 +122,16 @@ static bool read_uint16_internal(private_bio_reader_t *this, uint16_t *res,
 static bool read_uint24_internal(private_bio_reader_t *this, uint32_t *res,
                                                                 bool from_end)
 {
+       uint32_t tmp;
+
        if (this->buf.len < 3)
        {
                DBG1(DBG_LIB, "%d bytes insufficient to parse u_int24 data",
                         this->buf.len);
                return FALSE;
        }
-       *res = untoh32(get_ptr_end(this, 3, from_end)) >> 8;
+       memcpy(&tmp, get_ptr_end(this, 3, from_end), 3);
+       *res = ntohl(tmp) >> 8;
        this->buf = chunk_skip_end(this->buf, 3, from_end);
        return TRUE;
 }