From patchwork Tue Dec 7 06:01:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 2125 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.31.255.6]) by backend41.mail.ord1d.rsapps.net with LMTP id 6GJENMyTr2ENUwAAqwncew (envelope-from ) for ; Tue, 07 Dec 2021 12:03:08 -0500 Received: from proxy18.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id kPg2J8yTr2GhVQAAIasKDg (envelope-from ) for ; Tue, 07 Dec 2021 12:03:08 -0500 Received: from smtp23.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy18.mail.iad3b.rsapps.net with LMTPS id 8A24Dc2Tr2F+aQAA3NpJmQ (envelope-from ) for ; Tue, 07 Dec 2021 12:03:09 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp23.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 8ccceb5a-577f-11ec-864c-525400aa5716-1-1 Received: from [216.105.38.7] ([216.105.38.7:60348] helo=lists.sourceforge.net) by smtp23.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 79/36-27394-CC39FA16; Tue, 07 Dec 2021 12:03:08 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1mudrC-0000tG-HW; Tue, 07 Dec 2021 17:02:22 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mudrA-0000sn-2C for openvpn-devel@lists.sourceforge.net; Tue, 07 Dec 2021 17:02:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8vMA6hMfcqpYIOJrhu1psGvo1zRNeuWdLDl4bLvEE/8=; b=Xk8Ou/pemVZKxQoOFZFygDWalY tkePJw8loXaVLUN+7xTVCGPAeswwKfRFevEdMUZ5loBTar2M+h8qDnq6wloCLpPDhusjDJXjmOf5C mhlk/P7/Rh5FoHNHxpC7cswGBwQOtX5efCfcNRiXk3l85Thw7BX+gnuDicTRcTiKIOiw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=8vMA6hMfcqpYIOJrhu1psGvo1zRNeuWdLDl4bLvEE/8=; b=exbds7pmlyvDrN66wfQcf4CyuB 8Gh57AV+5XZxt/M1SXo20Y52nzYo1Std6Bj3C7APq67YGqNrakvpfDEmq8ffJc741j7ATR3Yj0luZ Uu80kq0w/XgjsIvDYBKeIZWx+4TGwAyrh+nqUeidgegvfvGZ83bv88ftMea5ta/MT9wk=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mudr8-007aK7-Ct for openvpn-devel@lists.sourceforge.net; Tue, 07 Dec 2021 17:02:19 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94.2 (FreeBSD)) (envelope-from ) id 1mudr1-000Idd-8e for openvpn-devel@lists.sourceforge.net; Tue, 07 Dec 2021 18:02:11 +0100 Received: (nullmailer pid 3275886 invoked by uid 10006); Tue, 07 Dec 2021 17:02:11 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Tue, 7 Dec 2021 18:01:51 +0100 Message-Id: <20211207170211.3275837-2-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207170211.3275837-1-arne@rfc2549.org> References: <20211207170211.3275837-1-arne@rfc2549.org> MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This argument is never used apart from a unit test. Remove this argument as a small cleanup. Signed-off-by: Arne Schwabe --- src/openvpn/buffer.c | 7 +++---- src/openvpn/buffer.h | 4 +--- src/openvpn/manage.c | 4 ++-- src/openvpn/ssl.c | 2 +- tests/unit_tests/openvpn/test_b [...] Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-Headers-End: 1mudr8-007aK7-Ct Subject: [Openvpn-devel] [PATCH 01/21] Remove max_size from buffer_list_new X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This argument is never used apart from a unit test. Remove this argument as a small cleanup. Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/buffer.c | 7 +++---- src/openvpn/buffer.h | 4 +--- src/openvpn/manage.c | 4 ++-- src/openvpn/ssl.c | 2 +- tests/unit_tests/openvpn/test_buffer.c | 22 ++++------------------ 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 486a77548..e9afb6d6a 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -1171,11 +1171,10 @@ valign4(const struct buffer *buf, const char *file, const int line) * struct buffer_list */ struct buffer_list * -buffer_list_new(const int max_size) +buffer_list_new() { struct buffer_list *ret; ALLOC_OBJ_CLEAR(ret, struct buffer_list); - ret->max_size = max_size; ret->size = 0; return ret; } @@ -1229,7 +1228,7 @@ struct buffer_entry * buffer_list_push_data(struct buffer_list *ol, const void *data, size_t size) { struct buffer_entry *e = NULL; - if (data && (!ol->max_size || ol->size < ol->max_size)) + if (data) { ALLOC_OBJ_CLEAR(e, struct buffer_entry); @@ -1359,7 +1358,7 @@ buffer_list_file(const char *fn, int max_line_len) char *line = (char *) malloc(max_line_len); if (line) { - bl = buffer_list_new(0); + bl = buffer_list_new(); while (fgets(line, max_line_len, fp) != NULL) { buffer_list_push(bl, line); diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index 8cc03c08f..619c3a95d 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -1102,11 +1102,9 @@ struct buffer_list /** * Allocate an empty buffer list of capacity \c max_size. * - * @param max_size the capacity of the list to allocate - * * @return the new list */ -struct buffer_list *buffer_list_new(const int max_size); +struct buffer_list *buffer_list_new(); /** * Frees a buffer list and all the buffers in it. diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 28315b82a..1f408f0b5 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -878,7 +878,7 @@ in_extra_reset(struct man_connection *mc, const int mode) } if (mode == IER_NEW) { - mc->in_extra = buffer_list_new(0); + mc->in_extra = buffer_list_new(); } } } @@ -2507,7 +2507,7 @@ man_connection_init(struct management *man) * command output from/to the socket. */ man->connection.in = command_line_new(1024); - man->connection.out = buffer_list_new(0); + man->connection.out = buffer_list_new(); /* * Initialize event set for standalone usage, when we are diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 0d811f24e..05096ee0a 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -3989,7 +3989,7 @@ tls_send_payload(struct tls_multi *multi, { if (!ks->paybuf) { - ks->paybuf = buffer_list_new(0); + ks->paybuf = buffer_list_new(); } buffer_list_push_data(ks->paybuf, data, (size_t)size); ret = true; diff --git a/tests/unit_tests/openvpn/test_buffer.c b/tests/unit_tests/openvpn/test_buffer.c index 5e854c22e..ac701669f 100644 --- a/tests/unit_tests/openvpn/test_buffer.c +++ b/tests/unit_tests/openvpn/test_buffer.c @@ -67,18 +67,18 @@ static int test_buffer_list_setup(void **state) { struct test_buffer_list_aggregate_ctx *ctx = calloc(1, sizeof(*ctx)); - ctx->empty = buffer_list_new(0); + ctx->empty = buffer_list_new(); - ctx->one_two_three = buffer_list_new(3); + ctx->one_two_three = buffer_list_new(); buffer_list_push(ctx->one_two_three, teststr1); buffer_list_push(ctx->one_two_three, teststr2); buffer_list_push(ctx->one_two_three, teststr3); - ctx->zero_length_strings = buffer_list_new(2); + ctx->zero_length_strings = buffer_list_new(); buffer_list_push(ctx->zero_length_strings, ""); buffer_list_push(ctx->zero_length_strings, ""); - ctx->empty_buffers = buffer_list_new(2); + ctx->empty_buffers = buffer_list_new(); uint8_t data = 0; buffer_list_push_data(ctx->empty_buffers, &data, 0); buffer_list_push_data(ctx->empty_buffers, &data, 0); @@ -100,17 +100,6 @@ test_buffer_list_teardown(void **state) return 0; } -static void -test_buffer_list_full(void **state) -{ - struct test_buffer_list_aggregate_ctx *ctx = *state; - - /* list full */ - assert_int_equal(ctx->one_two_three->size, 3); - buffer_list_push(ctx->one_two_three, teststr4); - assert_int_equal(ctx->one_two_three->size, 3); -} - static void test_buffer_list_aggregate_separator_empty(void **state) { @@ -247,9 +236,6 @@ main(void) { const struct CMUnitTest tests[] = { cmocka_unit_test(test_buffer_strprefix), - cmocka_unit_test_setup_teardown(test_buffer_list_full, - test_buffer_list_setup, - test_buffer_list_teardown), cmocka_unit_test_setup_teardown(test_buffer_list_aggregate_separator_empty, test_buffer_list_setup, test_buffer_list_teardown),