From d386394aad8a9c41f27cb9bef83dbc03b5aece97 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Tue, 10 Nov 2015 21:20:12 -0800 Subject: [PATCH] Test for underflow before subtraction. Found with -Wtype-limits. Change-Id: I41cdbb7e6564b715dfe445877a89594371fdeef0 Signed-off-by: Piotr Sikora Reviewed-on: https://boringssl-review.googlesource.com/6462 Reviewed-by: Adam Langley --- crypto/bio/pair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/bio/pair.c b/crypto/bio/pair.c index 6f788903..fba4be2c 100644 --- a/crypto/bio/pair.c +++ b/crypto/bio/pair.c @@ -256,8 +256,8 @@ int BIO_zero_copy_get_read_buf_done(BIO* bio, size_t bytes_read) { return 0; } + assert(peer_b->len >= bytes_read); peer_b->len -= bytes_read; - assert(peer_b->len >= 0); assert(peer_b->offset + bytes_read <= peer_b->size); /* Move read offset. If zero_copy_write_lock == 1 we must advance the