From be79d7658432cc2c55765b45ba493d53714862ae Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 9 Dec 2022 17:23:05 +0000 Subject: [PATCH] bio chain test: add a consistency check for chain lengths --- regress/lib/libcrypto/bio/bio_chain.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/regress/lib/libcrypto/bio/bio_chain.c b/regress/lib/libcrypto/bio/bio_chain.c index 34c7594417f..f5c46d710be 100644 --- a/regress/lib/libcrypto/bio/bio_chain.c +++ b/regress/lib/libcrypto/bio/bio_chain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_chain.c,v 1.10 2022/12/09 07:53:06 tb Exp $ */ +/* $OpenBSD: bio_chain.c,v 1.11 2022/12/09 17:23:05 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -396,6 +396,14 @@ link_chains_at(size_t i, size_t j, int use_bio_push) oldtail_len = nitems(A) - i - 1; } + /* The two chains A[] and B[] are split into three disjoint pieces. */ + if (nitems(A) + nitems(B) != new_len + oldtail_len + oldhead_len) { + fprintf(stderr, "%s case (%zu, %zu) inconsistent lengths: " + "%zu + %zu + %zu != %zu + %zu\n", fn, i, j, + nitems(A), nitems(B), new_len, oldtail_len, oldhead_len); + goto err; + } + /* * Now actually push or set next. */ -- 2.20.1