Fix all sign/unsigned warnings with Clang and GCC. Change-Id: If2a83698236f7b0dcd46701ccd257a85463d6ce5 Reviewed-on: https://boringssl-review.googlesource.com/4992 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/bio/bio.c b/crypto/bio/bio.c index 4bc98ba..7a1a9e3 100644 --- a/crypto/bio/bio.c +++ b/crypto/bio/bio.c
@@ -529,7 +529,7 @@ uint8_t header[6]; static const size_t kInitialHeaderLen = 2; - if (BIO_read(bio, header, kInitialHeaderLen) != kInitialHeaderLen) { + if (BIO_read(bio, header, kInitialHeaderLen) != (int) kInitialHeaderLen) { return 0; } @@ -559,7 +559,8 @@ return 0; } - if (BIO_read(bio, header + kInitialHeaderLen, num_bytes) != num_bytes) { + if (BIO_read(bio, header + kInitialHeaderLen, num_bytes) != + (int)num_bytes) { return 0; } header_len = kInitialHeaderLen + num_bytes; @@ -585,7 +586,8 @@ } if (len + header_len < len || - len + header_len > max_len) { + len + header_len > max_len || + len > INT_MAX) { return 0; } len += header_len; @@ -597,7 +599,7 @@ } memcpy(*out, header, header_len); if (BIO_read(bio, (*out) + header_len, len - header_len) != - len - header_len) { + (int) (len - header_len)) { OPENSSL_free(*out); return 0; }
diff --git a/crypto/bio/bio_mem.c b/crypto/bio/bio_mem.c index ef56111..6864f6f 100644 --- a/crypto/bio/bio_mem.c +++ b/crypto/bio/bio_mem.c
@@ -176,7 +176,7 @@ if (INT_MAX - blen < inl) { goto err; } - if (BUF_MEM_grow_clean(b, blen + inl) != (blen + inl)) { + if (BUF_MEM_grow_clean(b, blen + inl) != ((size_t) blen) + inl) { goto err; } memcpy(&b->data[blen], in, inl);
diff --git a/crypto/bio/printf.c b/crypto/bio/printf.c index 2f5ae4a..3709fcb 100644 --- a/crypto/bio/printf.c +++ b/crypto/bio/printf.c
@@ -87,7 +87,11 @@ } #endif - if (out_len >= sizeof(buf)) { + if (out_len < 0) { + return -1; + } + + if ((size_t) out_len >= sizeof(buf)) { const int requested_len = out_len; /* The output was truncated. Note that vsnprintf's return value * does not include a trailing NUL, but the buffer must be sized