more strict check in rioConnRead (#7564)

This commit is contained in:
zhaozhao.zz 2020-07-24 14:40:19 +08:00 committed by GitHub
parent 8a57969fd7
commit da840e9851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -201,7 +201,7 @@ static size_t rioConnRead(rio *r, void *buf, size_t len) {
/* Make sure the caller didn't request to read past the limit.
* If they didn't we'll buffer till the limit, if they did, we'll
* return an error. */
if (r->io.conn.read_limit >= r->io.conn.read_so_far + needs)
if (r->io.conn.read_limit >= r->io.conn.read_so_far + len)
toread = r->io.conn.read_limit - r->io.conn.read_so_far - buffered;
else {
errno = EOVERFLOW;