Skip to content

Commit

Permalink
Backport buffer over-read prevention from dav1d 1.4.3 (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbossen authored Jul 18, 2024
2 parents f8a015f + ce56fd9 commit a6a2373
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/input/annexb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ unsafe fn parse_obu_header(
buf = buf.offset(1);
buf_size -= 1;
if extension_flag != 0 {
if buf_size == 0 {
return -1;
}
buf = buf.offset(1);
buf_size -= 1;
}
Expand Down
2 changes: 2 additions & 0 deletions tools/input/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ static inline int parse_obu_header(const uint8_t *buf, int buf_size,
buf_size--;

if (extension_flag) {
if (!buf_size)
return -1;
buf++;
buf_size--;
// ignore fields
Expand Down
3 changes: 3 additions & 0 deletions tools/input/section5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ unsafe fn parse_obu_header(
buf = buf.offset(1);
buf_size -= 1;
if extension_flag != 0 {
if buf_size == 0 {
return -1;
}
buf = buf.offset(1);
buf_size -= 1;
}
Expand Down

0 comments on commit a6a2373

Please sign in to comment.