shithub: openh264

Download patch

ref: e90068c234a8f93df01b30b0d3de9ca8d8915c1d
parent: 6ba10ce6f318218b37e42fe66618c30d2f517b65
author: Haibo Zhu <haibozhu@cisco.com>
date: Tue Aug 11 08:56:09 EDT 2015

Add protection about emulation_prevention_three_byte error bytes

--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -669,10 +669,15 @@
           (0 == LD16 (pSrcNal + iSrcIdx)) &&
           ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) {
         if (pSrcNal[2 + iSrcIdx] == 0x03) {
-          ST16 (pDstNal + iDstIdx, 0);
-          iDstIdx      += 2;
-          iSrcIdx      += 3;
-          iSrcConsumed += 3;
+          if ((3 + iSrcConsumed < iSrcLength) && pSrcNal[3 + iSrcIdx] > 0x03) {
+            pCtx->iErrorCode |= dsBitstreamError;
+            return pCtx->iErrorCode;
+          } else {
+            ST16 (pDstNal + iDstIdx, 0);
+            iDstIdx      += 2;
+            iSrcIdx      += 3;
+            iSrcConsumed += 3;
+          }
         } else {
 
           iConsumedBytes = 0;