Test for underflow before subtraction. Found with -Wtype-limits. Change-Id: I41cdbb7e6564b715dfe445877a89594371fdeef0 Signed-off-by: Piotr Sikora <piotrsikora@google.com> Reviewed-on: https://boringssl-review.googlesource.com/6462 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/bio/pair.c b/crypto/bio/pair.c index 6f78890..fba4be2 100644 --- a/crypto/bio/pair.c +++ b/crypto/bio/pair.c
@@ -256,8 +256,8 @@ 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