Commit f7f88018 authored by Yusuke Nakamura's avatar Yusuke Nakamura Committed by Mickaël Raulet

hevc: Search start code in decode_nal_units().

User may cut off a weird position and send a packet from there.
This avoids returning as invalid data immediately.
parent 610a8b15
...@@ -2325,14 +2325,15 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) ...@@ -2325,14 +2325,15 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
goto fail; goto fail;
} }
} else { } else {
if (buf[2] == 0) { /* search start code */
length--; while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
buf++; ++buf;
continue; --length;
} if (length < 4) {
if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { av_log(s->avctx, AV_LOG_ERROR, "No start code is found.\n");
ret = AVERROR_INVALIDDATA; ret = AVERROR_INVALIDDATA;
goto fail; goto fail;
}
} }
buf += 3; buf += 3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment