Skip to content

fix signed shift overflow in WavpackOpenRawDecoder header parsing#235

Merged
dbry merged 1 commit into
dbry:masterfrom
aizu-m:raw-decoder-shift-overflow
Jun 2, 2026
Merged

fix signed shift overflow in WavpackOpenRawDecoder header parsing#235
dbry merged 1 commit into
dbry:masterfrom
aizu-m:raw-decoder-shift-overflow

Conversation

@aizu-m
Copy link
Copy Markdown
Contributor

@aizu-m aizu-m commented Jun 2, 2026

UBSan from clang -fsanitize=shift, driving WavpackOpenRawDecoder with Matroska-style raw blocks (no "wvpk" header) whose reconstructed header bytes have the high bit set:

open_raw.c:163:41: runtime error: left shift of 128 by 24 places
  cannot be represented in type 'int'

The bytes promote to int before the << 24, so any top byte >= 0x80 overflows the sign bit. Cast to uint32_t for the six block_samples/flags/crc/block_size fields, as WavpackLittleEndianToNative already does.

@dbry
Copy link
Copy Markdown
Owner

dbry commented Jun 2, 2026

Thanks!

@dbry dbry merged commit e410e73 into dbry:master Jun 2, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants