summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorYusuke Nakamura <muken.the.vfrmaniac@gmail.com>2013-10-21 02:36:51 +0900
committerMickaƫl Raulet <mraulet@insa-rennes.fr>2013-10-27 10:43:14 +0100
commitf7f88018393b96ae410041e9a0fc51f4c082002e (patch)
treed366cc464f179aa70355faaa9a780b4adcfed158 /libavcodec
parent610a8b1537fe728f4f1e44a5276f225334653123 (diff)
downloadffmpeg-streaming-f7f88018393b96ae410041e9a0fc51f4c082002e.zip
ffmpeg-streaming-f7f88018393b96ae410041e9a0fc51f4c082002e.tar.gz
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.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/hevc.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index a395bc9..9a88867 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2325,14 +2325,15 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
goto fail;
}
} else {
- if (buf[2] == 0) {
- length--;
- buf++;
- continue;
- }
- if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
- ret = AVERROR_INVALIDDATA;
- goto fail;
+ /* search start code */
+ while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
+ ++buf;
+ --length;
+ if (length < 4) {
+ av_log(s->avctx, AV_LOG_ERROR, "No start code is found.\n");
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
}
buf += 3;
OpenPOWER on IntegriCloud