Handle 2-byte submessage lengths.

pull/13171/head
Joshua Haberman 4 years ago
parent 88b1ec7784
commit 405e7934b1
  1. 4
      upb/decode.c
  2. 11
      upb/decode_fast.c

@ -694,7 +694,11 @@ bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l,
decode_stealmem(&state);
#ifdef __APPLE__
if (_setjmp(state.err)) {
#else
if (setjmp(state.err)) {
#endif
ret = false;
} else {
decode_msg(&state, buf, msg, l);

@ -262,9 +262,14 @@ again:
}
{
int64_t len = ptr[tagbytes];
if (UPB_UNLIKELY(len < 0)) {
return fastdecode_generic(UPB_PARSE_ARGS);
uint32_t len = (uint8_t)ptr[tagbytes];
if (UPB_UNLIKELY(len & 0x80)) {
uint32_t byte = (uint8_t)ptr[tagbytes + 1];
len += (byte - 1) << 7;
if (UPB_UNLIKELY(byte & 0x80)) {
return fastdecode_generic(UPB_PARSE_ARGS);
}
ptr++;
}
ptr += tagbytes + 1;
if (UPB_UNLIKELY(fastdecode_boundscheck(ptr, len, d->limit))) {

Loading…
Cancel
Save