diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2019-01-23 22:20:41 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2019-01-23 22:20:41 +0000 |
commit | 895f6c3a8980ba4a15f47b7de7d56eed0260efb2 (patch) | |
tree | 27765fe119783d634df40f9878d84f3ce3851eab | |
parent | 8cd2926ea4ada4dac877f1e3882a606f2a39edf6 (diff) |
assert.h is often misused. It should not be used in a library
ok bcook@ jsing@
-rw-r--r-- | lib/libssl/bs_cbb.c | 6 | ||||
-rw-r--r-- | lib/libssl/bs_cbs.c | 7 |
2 files changed, 5 insertions, 8 deletions
diff --git a/lib/libssl/bs_cbb.c b/lib/libssl/bs_cbb.c index beb588fe25d..a34e822c942 100644 --- a/lib/libssl/bs_cbb.c +++ b/lib/libssl/bs_cbb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbb.c,v 1.19 2018/08/16 18:39:37 jsing Exp $ */ +/* $OpenBSD: bs_cbb.c,v 1.20 2019/01/23 22:20:40 beck Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -14,7 +14,6 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <assert.h> #include <stdlib.h> #include <string.h> @@ -214,7 +213,8 @@ CBB_flush(CBB *cbb) uint8_t initial_length_byte; /* We already wrote 1 byte for the length. */ - assert (cbb->pending_len_len == 1); + if (cbb->pending_len_len != 1) + return 0; /* Check for long form */ if (len > 0xfffffffe) diff --git a/lib/libssl/bs_cbs.c b/lib/libssl/bs_cbs.c index ea1f0108f61..5c3b9e3ec6c 100644 --- a/lib/libssl/bs_cbs.c +++ b/lib/libssl/bs_cbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbs.c,v 1.17 2015/06/24 09:44:18 jsing Exp $ */ +/* $OpenBSD: bs_cbs.c,v 1.18 2019/01/23 22:20:40 beck Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -14,7 +14,6 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <assert.h> #include <stdlib.h> #include <string.h> @@ -347,10 +346,8 @@ cbs_get_asn1(CBS *cbs, CBS *out, unsigned int tag_value, int skip_header) tag != tag_value) return 0; - if (skip_header && !CBS_skip(out, header_len)) { - assert(0); + if (skip_header && !CBS_skip(out, header_len)) return 0; - } return 1; } |