History

atrac3: avoid oversized shifting in decode_bytes()

When `off' is 0, `0x537F6103 << 32' in the following expression invokes undefined behavior, the result of which is not necessarily 0. (0x537F6103 >> (off * 8)) | (0x537F6103 << (32 - (off * 8))) Avoid oversized shifting. CC: libav-stable@libav.org

Xi Wang committed 13 years ago

Commit eba1ff31 parent c42e2621 file · +4 −1Browse files

Unified · Split

libavcodec/atrac3.c+4−1
@@ -163,7 +163,10 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes) · 162 unmodified lines
163163
164164 off = (intptr_t)input & 3;
165165 buf = (const uint32_t *)(input - off);
166− c = av_be2ne32((0x537F6103 >> (off * 8)) | (0x537F6103 << (32 - (off * 8))));
166+ if (off)
167+ c = av_be2ne32((0x537F6103U >> (off * 8)) | (0x537F6103U << (32 - (off * 8))));
168+ else
169+ c = av_be2ne32(0x537F6103U);
167170 bytes += 3 + off;
168171 for (i = 0; i < bytes / 4; i++)
169172 output[i] = c ^ buf[i];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t