History

flacdec: simplify bounds checking in flac_probe()

Simplify `p->buf > p->buf + p->buf_size - 4' as `p->buf_size < 4'. Avoid a possible out-of-bounds pointer, which is undefined behavior in C. CC: libav-stable@libav.org

Xi Wang committed 13 years ago

Commit 8425d691 parent eba1ff31 file · +3 −5Browse files

Unified · Split

libavformat/flacdec.c+3−5
@@ -279,11 +279,9 @@ static int flac_read_header(AVFormatContext *s) · 278 unmodified lines
279279
280280 static int flac_probe(AVProbeData *p)
281281 {
282− uint8_t *bufptr = p->buf;
283− uint8_t *end = p->buf + p->buf_size;
284−
285− if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
286− else return AVPROBE_SCORE_MAX/2;
282+ if (p->buf_size < 4 || memcmp(p->buf, "fLaC", 4))
283+ return 0;
284+ return AVPROBE_SCORE_MAX/2;
287285 }
288286
289287 AVInputFormat ff_flac_demuxer = {

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