evtag: detect tags over 32-bits earlier

This commit is contained in:
Nick Mathewson 2014-03-18 12:27:14 -04:00
parent e660db6d5f
commit 31c491504e

View File

@ -210,7 +210,14 @@ decode_tag_internal(ev_uint32_t *ptag, struct evbuffer *evbuf, int dodrain)
while (count++ < len) {
ev_uint8_t lower = *data++;
number |= (lower & 0x7f) << shift;
if (shift >= 28) {
/* Make sure it fits into 32 bits */
if (shift > 28)
return (-1);
if ((lower & 0x7f) > 15)
return (-1);
}
number |= (lower & (unsigned)0x7f) << shift;
shift += 7;
if (!(lower & 0x80)) {