Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for overflow in off_t when parsing chunks #781

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading