mirror of
https://github.com/webmproject/libwebp.git
synced 2025-08-29 15:22:12 +02:00
Merge "Add fbounds-safety annotations for VP8BitReader
." into main
This commit is contained in:
@@ -85,6 +85,7 @@ static WEBP_UBSAN_IGNORE_UNDEF WEBP_INLINE void VP8LoadNewBytes(
|
|||||||
WEBP_UNSAFE_MEMCPY(&in_bits, br->buf, sizeof(in_bits));
|
WEBP_UNSAFE_MEMCPY(&in_bits, br->buf, sizeof(in_bits));
|
||||||
#endif
|
#endif
|
||||||
br->buf += BITS >> 3;
|
br->buf += BITS >> 3;
|
||||||
|
WEBP_SELF_ASSIGN(br->buf_end);
|
||||||
#if !defined(WORDS_BIGENDIAN)
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
#if (BITS > 32)
|
#if (BITS > 32)
|
||||||
bits = BSwap64(in_bits);
|
bits = BSwap64(in_bits);
|
||||||
|
@@ -31,7 +31,8 @@ WEBP_ASSUME_UNSAFE_INDEXABLE_ABI
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// VP8BitReader
|
// VP8BitReader
|
||||||
|
|
||||||
void VP8BitReaderSetBuffer(VP8BitReader* const br, const uint8_t* const start,
|
void VP8BitReaderSetBuffer(VP8BitReader* const br,
|
||||||
|
const uint8_t* const WEBP_COUNTED_BY(size) start,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
assert(start != NULL);
|
assert(start != NULL);
|
||||||
br->buf = start;
|
br->buf = start;
|
||||||
@@ -40,7 +41,8 @@ void VP8BitReaderSetBuffer(VP8BitReader* const br, const uint8_t* const start,
|
|||||||
(size >= sizeof(lbit_t)) ? start + size - sizeof(lbit_t) + 1 : start;
|
(size >= sizeof(lbit_t)) ? start + size - sizeof(lbit_t) + 1 : start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VP8InitBitReader(VP8BitReader* const br, const uint8_t* const start,
|
void VP8InitBitReader(VP8BitReader* const br,
|
||||||
|
const uint8_t* const WEBP_COUNTED_BY(size) start,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
assert(br != NULL);
|
assert(br != NULL);
|
||||||
assert(start != NULL);
|
assert(start != NULL);
|
||||||
@@ -87,6 +89,7 @@ void VP8LoadFinalBytes(VP8BitReader* const br) {
|
|||||||
if (br->buf < br->buf_end) {
|
if (br->buf < br->buf_end) {
|
||||||
br->bits += 8;
|
br->bits += 8;
|
||||||
br->value = (bit_t)(*br->buf++) | (br->value << 8);
|
br->value = (bit_t)(*br->buf++) | (br->value << 8);
|
||||||
|
WEBP_SELF_ASSIGN(br->buf_end);
|
||||||
} else if (!br->eof) {
|
} else if (!br->eof) {
|
||||||
br->value <<= 8;
|
br->value <<= 8;
|
||||||
br->bits += 8;
|
br->bits += 8;
|
||||||
|
@@ -103,17 +103,20 @@ struct VP8BitReader {
|
|||||||
range_t range; // current range minus 1. In [127, 254] interval.
|
range_t range; // current range minus 1. In [127, 254] interval.
|
||||||
int bits; // number of valid bits left
|
int bits; // number of valid bits left
|
||||||
// read buffer
|
// read buffer
|
||||||
const uint8_t* buf; // next byte to be read
|
const uint8_t* WEBP_ENDED_BY(buf_end) buf; // next byte to be read
|
||||||
const uint8_t* buf_end; // end of read buffer
|
const uint8_t* buf_end; // end of read buffer
|
||||||
const uint8_t* buf_max; // max packed-read position on buffer
|
// max packed-read position on buffer
|
||||||
int eof; // true if input is exhausted
|
const uint8_t* WEBP_UNSAFE_INDEXABLE buf_max;
|
||||||
|
int eof; // true if input is exhausted
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize the bit reader and the boolean decoder.
|
// Initialize the bit reader and the boolean decoder.
|
||||||
void VP8InitBitReader(VP8BitReader* const br, const uint8_t* const start,
|
void VP8InitBitReader(VP8BitReader* const br,
|
||||||
|
const uint8_t* const WEBP_COUNTED_BY(size) start,
|
||||||
size_t size);
|
size_t size);
|
||||||
// Sets the working read buffer.
|
// Sets the working read buffer.
|
||||||
void VP8BitReaderSetBuffer(VP8BitReader* const br, const uint8_t* const start,
|
void VP8BitReaderSetBuffer(VP8BitReader* const br,
|
||||||
|
const uint8_t* const WEBP_COUNTED_BY(size) start,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
// Update internal pointers to displace the byte buffer by the
|
// Update internal pointers to displace the byte buffer by the
|
||||||
|
Reference in New Issue
Block a user