mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-01 20:36:38 -05:00
Fix undefined behavior in STREAM buffer bounds checking by avoiding out-of-bounds pointer arithmetic
This commit is contained in:
parent
3185e1bf34
commit
608393867a
2 changed files with 4 additions and 3 deletions
|
|
@ -152,9 +152,10 @@ uint32_t scrc_stream(STREAM* s);
|
|||
/**
|
||||
* Check if the buffer has enough data loaded.
|
||||
*/
|
||||
static inline int sptrlookup(STREAM* s, ssize_t size)
|
||||
static inline int sptrlookup(STREAM* s, size_t size)
|
||||
{
|
||||
return s->pos + size <= s->end;
|
||||
/* compute remaining distance to avoid pointer arithmetic out of buffer bounds */
|
||||
return size <= (size_t)(s->end - s->pos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue