History

avformat/s337m: fix potentially undefined pointer arithmetic

Use integer position instead of pointer for loop variable. Also only skip header fields after header has been fully validated.

foo86 committed 9 years ago

Commit 6029b8a1 parent 5e715b51 file · +10 −10Browse files

Showing the changes to libavformat (1 of 1 file). Show all

Unified · Split

libavformat/s337m.c+10−10
@@ -86,22 +86,21 @@ static int s337m_probe(AVProbeData *p) · 85 unmodified lines
86{86{
87 uint64_t state = 0;87 uint64_t state = 0;
88 int markers[3] = { 0 };88 int markers[3] = { 0 };
89 int i, sum, max, data_type, data_size, offset;89 int i, pos, sum, max, data_type, data_size, offset;
90 uint8_t *buf;90 uint8_t *buf;
91 91
92 for (buf = p->buf; buf < p->buf + p->buf_size; buf++) {92 for (pos = 0; pos < p->buf_size; pos++) {
93 state = (state << 8) | *buf;93 state = (state << 8) | p->buf[pos];
94 if (!IS_LE_MARKER(state))94 if (!IS_LE_MARKER(state))
95 continue;95 continue;
96 96
97 buf = p->buf + pos + 1;
97 if (IS_16LE_MARKER(state)) {98 if (IS_16LE_MARKER(state)) {
98 data_type = AV_RL16(buf + 1);99 data_type = AV_RL16(buf );
99 data_size = AV_RL16(buf + 3);100 data_size = AV_RL16(buf + 2);
100 buf += 4;
101 } else {101 } else {
102 data_type = AV_RL24(buf + 1);102 data_type = AV_RL24(buf );
103 data_size = AV_RL24(buf + 4);103 data_size = AV_RL24(buf + 3);
104 buf += 6;
105 }104 }
106 105
107 if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, &offset, NULL))106 if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, &offset, NULL))
@@ -110,7 +109,8 @@ static int s337m_probe(AVProbeData *p) · 2 unmodified lines
110 i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;109 i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
111 markers[i]++;110 markers[i]++;
112 111
113 buf += offset;112 pos += IS_16LE_MARKER(state) ? 4 : 6;
113 pos += offset;
114 state = 0;114 state = 0;
115 }115 }
116 116

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t