Commit 72f9a634 authored by Bryan Huh's avatar Bryan Huh Committed by Michael Niedermayer

avformat/cache: Avoid int-overflow in cache compare function

cache protocol indexes its cache using AVTreeNodes which require a cmp
function for inserting and searching new cache-entries. This cmp
function expects a 32-bit int return value (negative, zero, or positive)
but the cache cmp function returns an int64_t which can overflow the
int, giving negative numbers for when it should be positive, vice versa.
This manifests itself only for very large files (e.g. 4GB+)
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent ddbad158
...@@ -67,7 +67,7 @@ typedef struct Context { ...@@ -67,7 +67,7 @@ typedef struct Context {
static int cmp(const void *key, const void *node) static int cmp(const void *key, const void *node)
{ {
return (*(const int64_t *) key) - ((const CacheEntry *) node)->logical_pos; return FFDIFFSIGN(*(const int64_t *)key, ((const CacheEntry *) node)->logical_pos);
} }
static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **options) static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **options)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment