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

Unified · Split

libavformat/s337m.c+10−10
@@ -86,22 +86,21 @@ static int s337m_probe(AVProbeData *p) · 85 unmodified lines
8686 {
8787 uint64_t state = 0;
8888 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;
9090 uint8_t *buf;
9191
92− for (buf = p->buf; buf < p->buf + p->buf_size; buf++) {
93− state = (state << 8) | *buf;
92+ for (pos = 0; pos < p->buf_size; pos++) {
93+ state = (state << 8) | p->buf[pos];
9494 if (!IS_LE_MARKER(state))
9595 continue;
9696
97+ buf = p->buf + pos + 1;
9798 if (IS_16LE_MARKER(state)) {
98− data_type = AV_RL16(buf + 1);
99− data_size = AV_RL16(buf + 3);
100− buf += 4;
99+ data_type = AV_RL16(buf );
100+ data_size = AV_RL16(buf + 2);
101101 } else {
102− data_type = AV_RL24(buf + 1);
103− data_size = AV_RL24(buf + 4);
104− buf += 6;
102+ data_type = AV_RL24(buf );
103+ data_size = AV_RL24(buf + 3);
105104 }
106105
107106 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
110109 i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
111110 markers[i]++;
112111
113− buf += offset;
112+ pos += IS_16LE_MARKER(state) ? 4 : 6;
113+ pos += offset;
114114 state = 0;
115115 }
116116

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