Avoid sticking -1 into a size_t.
There's still a size_t/int cast due to the mass of legacy code, but at
least avoid the most egregious case.
Change-Id: Icc1741366e09190216e762ca7ef42ecfc3215edc
Reviewed-on: https://boringssl-review.googlesource.com/6345
Reviewed-by: Adam Langley <alangley@gmail.com>
diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c
index 8d4b163..5751f75 100644
--- a/crypto/x509/x509_lu.c
+++ b/crypto/x509/x509_lu.c
@@ -441,7 +441,6 @@
X509_CINF cinf_s;
X509_CRL crl_s;
X509_CRL_INFO crl_info_s;
- size_t idx;
stmp.type=type;
switch (type)
@@ -461,8 +460,11 @@
return -1;
}
- idx = -1;
- if (sk_X509_OBJECT_find(h, &idx, &stmp) && pnmatch)
+ size_t idx;
+ if (!sk_X509_OBJECT_find(h, &idx, &stmp))
+ return -1;
+
+ if (pnmatch != NULL)
{
int tidx;
const X509_OBJECT *tobj, *pstmp;