Skip to content

Commit a8adc6c

Browse files
authored
Check for overflow in off_t when parsing chunks (#781)
Credit: Oss-Fuzz Issue: https://issues.oss-fuzz.com/issues/42537590
1 parent 7f491ae commit a8adc6c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

include/share/compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
#define FLAC__OFF_T_MAX LONG_MAX
7171
#else
7272
#define FLAC__off_t off_t
73-
#define FLAC__OFF_T_MAX OFF_T_MAX
73+
#define FLAC__OFF_T_MAX (sizeof(off_t) == sizeof(int64_t) ? INT64_MAX : sizeof(off_t) == sizeof(int32_t) ? INT32_MAX : -999999)
7474
#endif
7575
#endif
7676

src/flac/encode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,6 +2915,9 @@ FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset)
29152915
static uint8_t dump[8192];
29162916
struct flac_stat_s stb;
29172917

2918+
if(offset > (FLAC__uint64)FLAC__OFF_T_MAX)
2919+
return false;
2920+
29182921
if(flac_fstat(fileno(f), &stb) == 0 && (stb.st_mode & S_IFMT) == S_IFREG)
29192922
{
29202923
if(fseeko(f, offset, SEEK_CUR) == 0)

0 commit comments

Comments
 (0)