diff options
| author | jsing <> | 2020-05-10 14:17:48 +0000 |
|---|---|---|
| committer | jsing <> | 2020-05-10 14:17:48 +0000 |
| commit | 4749b6f55a603d6923ae5901d112961ff3c56b38 (patch) | |
| tree | b66a408927dda1a4853152273bf1767b1576d8e2 /src/lib/libssl/s3_lib.c | |
| parent | 81c0dc68dcd1bad4e24db7fee4739e273ac59ca1 (diff) | |
| download | openbsd-4749b6f55a603d6923ae5901d112961ff3c56b38.tar.gz openbsd-4749b6f55a603d6923ae5901d112961ff3c56b38.tar.bz2 openbsd-4749b6f55a603d6923ae5901d112961ff3c56b38.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 '')
| -rw-r--r-- | src/lib/libssl/s3_lib.c | 22 |
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) | |||
| 1842 | static int | 1842 | static 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 | ||
| 1849 | static int | 1856 | static 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 | ||
