Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: patches/to_upstream/55_h264_nal.patch

Issue 9340008: Avoid OOB reads in nal parsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « patches/README ('k') | source/patched-ffmpeg/libavcodec/h264.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 diff -wurp -N orig/libavcodec/h264.c ffmpeg/libavcodec/h264.c
2 --- orig/libavcodec/h264.c 2012-02-06 14:02:09.990431439 -0800
3 +++ ffmpeg/libavcodec/h264.c 2012-02-06 14:06:11.752827405 -0800
4 @@ -988,12 +988,13 @@ int ff_h264_decode_extradata(H264Context
5 AVCodecContext *avctx = h->s.avctx;
6
7 if(avctx->extradata[0] == 1){
8 - int i, cnt, nalsize;
9 + int i, cnt, nalsize, size_left;
10 unsigned char *p = avctx->extradata;
11 + size_left = avctx->extradata_size;
12
13 h->is_avc = 1;
14
15 - if(avctx->extradata_size < 7) {
16 + if(size_left < 7) {
17 av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
18 return -1;
19 }
20 @@ -1003,23 +1004,47 @@ int ff_h264_decode_extradata(H264Context
21 // Decode sps from avcC
22 cnt = *(p+5) & 0x1f; // Number of sps
23 p += 6;
24 + size_left -= 6;
25 for (i = 0; i < cnt; i++) {
26 + if (size_left < 2) {
27 + av_log(avctx, AV_LOG_ERROR, "Cannot read sps nalsize\n");
28 + return -1;
29 + }
30 nalsize = AV_RB16(p) + 2;
31 + if (size_left < nalsize) {
32 + av_log(avctx, AV_LOG_ERROR, "sps nalsize too big\n");
33 + return -1;
34 + }
35 if(decode_nal_units(h, p, nalsize) < 0) {
36 av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n ", i);
37 return -1;
38 }
39 p += nalsize;
40 + size_left -= nalsize;
41 }
42 // Decode pps from avcC
43 + if(!size_left) {
44 + av_log(avctx, AV_LOG_ERROR, "Cannot read pps count\n");
45 + return -1;
46 + }
47 cnt = *(p++); // Number of pps
48 + --size_left;
49 for (i = 0; i < cnt; i++) {
50 + if (size_left < 2) {
51 + av_log(avctx, AV_LOG_ERROR, "Cannot read pps nalsize\n");
52 + return -1;
53 + }
54 nalsize = AV_RB16(p) + 2;
55 + if (size_left < nalsize) {
56 + av_log(avctx, AV_LOG_ERROR, "pps nalsize too big\n");
57 + return -1;
58 + }
59 if (decode_nal_units(h, p, nalsize) < 0) {
60 av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n ", i);
61 return -1;
62 }
63 p += nalsize;
64 + size_left -= nalsize;
65 }
66 // Now store right nal length size, that will be use to parse all other nals
67 h->nal_length_size = (avctx->extradata[4] & 0x03) + 1;
OLDNEW
« no previous file with comments | « patches/README ('k') | source/patched-ffmpeg/libavcodec/h264.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698