mirror of
https://github.com/fluencelabs/musl
synced 2025-06-12 06:21:39 +00:00
fix twos complement overflow bug in mem streams boundary check
the expression -off is not safe in case off is the most-negative value. instead apply - to base which is known to be non-negative and bounded within sanity.
This commit is contained in:
@ -29,7 +29,7 @@ static off_t wms_seek(FILE *f, off_t off, int whence)
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (-off > base || off > SSIZE_MAX/4-base) goto fail;
|
||||
if (off < -base || off > SSIZE_MAX/4-base) goto fail;
|
||||
memset(&c->mbs, 0, sizeof c->mbs);
|
||||
return c->pos = base+off;
|
||||
}
|
||||
|
Reference in New Issue
Block a user