summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s3_lib.c
diff options
context:
space:
mode:
authorjsing <>2020-05-10 14:17:48 +0000
committerjsing <>2020-05-10 14:17:48 +0000
commit2c5bb57394ae3bd0d749e60f9e5489396e6f7d75 (patch)
treeb66a408927dda1a4853152273bf1767b1576d8e2 /src/lib/libssl/s3_lib.c
parent460f8be5c360d203bab35f98b05092261d9701b0 (diff)
downloadopenbsd-2c5bb57394ae3bd0d749e60f9e5489396e6f7d75.tar.gz
openbsd-2c5bb57394ae3bd0d749e60f9e5489396e6f7d75.tar.bz2
openbsd-2c5bb57394ae3bd0d749e60f9e5489396e6f7d75.zip
Use size_t for OCSP response length.
The OCSP response length is currently an integer, which is overloaded with -1 meaning "unset". Use a size_t for the OCSP response length and infer unset from the OCSP response being NULL. This makes code more readable, simpler and less error prone. ok beck@
Diffstat (limited to 'src/lib/libssl/s3_lib.c')
-rw-r--r--src/lib/libssl/s3_lib.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 87b43a3521..afc798bedc 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.192 2020/04/18 14:07:56 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.193 2020/05/10 14:17:47 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1842,16 +1842,30 @@ _SSL_set_tlsext_status_ids(SSL *s, STACK_OF(OCSP_RESPID) *ids)
1842static int 1842static int
1843_SSL_get_tlsext_status_ocsp_resp(SSL *s, unsigned char **resp) 1843_SSL_get_tlsext_status_ocsp_resp(SSL *s, unsigned char **resp)
1844{ 1844{
1845 *resp = s->internal->tlsext_ocsp_resp; 1845 if (s->internal->tlsext_ocsp_resp != NULL &&
1846 return s->internal->tlsext_ocsp_resplen; 1846 s->internal->tlsext_ocsp_resp_len < INT_MAX) {
1847 *resp = s->internal->tlsext_ocsp_resp;
1848 return (int)s->internal->tlsext_ocsp_resp_len;
1849 }
1850
1851 *resp = NULL;
1852
1853 return -1;
1847} 1854}
1848 1855
1849static int 1856static int
1850_SSL_set_tlsext_status_ocsp_resp(SSL *s, unsigned char *resp, int resp_len) 1857_SSL_set_tlsext_status_ocsp_resp(SSL *s, unsigned char *resp, int resp_len)
1851{ 1858{
1852 free(s->internal->tlsext_ocsp_resp); 1859 free(s->internal->tlsext_ocsp_resp);
1860 s->internal->tlsext_ocsp_resp = NULL;
1861 s->internal->tlsext_ocsp_resp_len = 0;
1862
1863 if (resp_len < 0)
1864 return 0;
1865
1853 s->internal->tlsext_ocsp_resp = resp; 1866 s->internal->tlsext_ocsp_resp = resp;
1854 s->internal->tlsext_ocsp_resplen = resp_len; 1867 s->internal->tlsext_ocsp_resp_len = (size_t)resp_len;
1868
1855 return 1; 1869 return 1;
1856} 1870}
1857 1871