diff options
author | David Benjamin <davidben@chromium.org> | 2015-10-24 01:39:59 +0300 |
---|---|---|
committer | Adam Langley <alangley@gmail.com> | 2015-10-26 22:50:53 +0300 |
commit | ff905b09fc498150646e47d0b2340937782aeaa7 (patch) | |
tree | 3db9b760d7bcf57c00ecdfea5694dd8284fc1a8d /crypto/x509 | |
parent | 0a870c2f7e00ee4d6f54709adefc01015ea93f4c (diff) |
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>
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/x509_lu.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 8d4b1634..5751f758 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -441,7 +441,6 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type, 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 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type, 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; |