bio_reader: Fix read_uint24

This commit is contained in:
Andreas Steffen
2018-06-12 21:47:39 +02:00
parent 508b308768
commit e1833a90ba
+4 -1
View 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, static bool read_uint24_internal(private_bio_reader_t *this, uint32_t *res,
bool from_end) bool from_end)
{ {
uint32_t tmp;
if (this->buf.len < 3) if (this->buf.len < 3)
{ {
DBG1(DBG_LIB, "%d bytes insufficient to parse u_int24 data", DBG1(DBG_LIB, "%d bytes insufficient to parse u_int24 data",
this->buf.len); this->buf.len);
return FALSE; 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); this->buf = chunk_skip_end(this->buf, 3, from_end);
return TRUE; return TRUE;
} }