Skip to content

Commit

Permalink
Check for overflow in off_t when parsing chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmf01 committed Dec 27, 2024
1 parent 7f491ae commit 0a7b294
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/share/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#define FLAC__OFF_T_MAX LONG_MAX
#else
#define FLAC__off_t off_t
#define FLAC__OFF_T_MAX OFF_T_MAX
#define FLAC__OFF_T_MAX (sizeof(off_t) == sizeof(int64_t) ? INT64_MAX : sizeof(off_t) == sizeof(int32_t) ? INT32_MAX : -999999)
#endif
#endif

Expand Down
3 changes: 3 additions & 0 deletions src/flac/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,9 @@ FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset)
static uint8_t dump[8192];
struct flac_stat_s stb;

if(offset > (FLAC__uint64)FLAC__OFF_T_MAX)
return false;

if(flac_fstat(fileno(f), &stb) == 0 && (stb.st_mode & S_IFMT) == S_IFREG)
{
if(fseeko(f, offset, SEEK_CUR) == 0)
Expand Down

0 comments on commit 0a7b294

Please sign in to comment.