From patchwork Thu Dec 28 22:52:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 164 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director3.mail.ord1d.rsapps.net ([172.30.191.6]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id 7Q97AEgxTloTJQAAgoeIoA for ; Thu, 04 Jan 2018 08:51:04 -0500 Received: from proxy9.mail.ord1d.rsapps.net ([172.30.191.6]) by director3.mail.ord1d.rsapps.net (Dovecot) with LMTP id u7P7EEgxTlosQQAAkXNnRw ; Thu, 04 Jan 2018 08:51:04 -0500 Received: from smtp10.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy9.mail.ord1d.rsapps.net (Dovecot) with LMTP id oStUDUgxTlrDYQAA7h+8OQ ; Thu, 04 Jan 2018 08:51:04 -0500 X-Spam-Exception: WHITELISTED X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: patchwork@openvpn.net X-Originating-Ip: [184.106.54.93] Authentication-Results: smtp10.gate.ord1d.rsapps.net; iprev=pass policy.iprev="184.106.54.93"; spf=pass smtp.mailfrom="samuli@openvpn.net" smtp.helo="smtp93.ord1d.emailsrvr.com"; 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=fox-it.com X-Classification-ID: 4e2edaea-f156-11e7-b6a4-52540013bccb-1-1 Received: from [184.106.54.93] ([184.106.54.93:32809] helo=smtp93.ord1d.emailsrvr.com) by smtp10.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 22/4A-25340-7413E4A5; Thu, 04 Jan 2018 08:51:03 -0500 Received: from smtp20.relay.ord1d.emailsrvr.com (localhost [127.0.0.1]) by smtp20.relay.ord1d.emailsrvr.com (SMTP Server) with ESMTP id E0BA1C0080 for ; Thu, 4 Jan 2018 08:51:03 -0500 (EST) X-Auth-ID: samuli@openvpn.net Received: by smtp20.relay.ord1d.emailsrvr.com (Authenticated sender: samuli-AT-openvpn.net) with ESMTPSA id 60DBFC006B for ; Thu, 4 Jan 2018 08:51:03 -0500 (EST) X-Sender-Id: samuli@openvpn.net Received: from [192.168.15.45] (91-159-32-223.elisa-laajakaista.fi [91.159.32.223]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.7.12); Thu, 04 Jan 2018 08:51:03 -0500 Resent-From: =?utf-8?q?Samuli_Sepp=C3=A4nen?= Resent-To: patchwork@openvpn.net Resent-Date: Thu, 4 Jan 2018 15:51:01 +0200 Resent-Message-ID: Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 Received: from MBX10D-ORD1.mex06.mlsrvr.com (172.29.1.29) by MBX10C-ORD1.mex06.mlsrvr.com (172.29.1.28) with Microsoft SMTP Server (TLS) id 15.0.1293.2 via Mailbox Transport; Fri, 29 Dec 2017 03:53:19 -0600 Received: from MBX09D-ORD1.mex06.mlsrvr.com (172.29.1.26) by MBX10D-ORD1.mex06.mlsrvr.com (172.29.1.29) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Fri, 29 Dec 2017 03:53:19 -0600 Received: from gate.forward.smtp.iad3a.emailsrvr.com (204.232.172.40) by MBX09D-ORD1.mex06.mlsrvr.com (172.29.1.26) with Microsoft SMTP Server (TLS) id 15.0.1293.2 via Frontend Transport; Fri, 29 Dec 2017 03:53:19 -0600 Received: from [216.34.181.88] ([216.34.181.88:50772] helo=lists.sourceforge.net) by smtp18.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 9F/C1-05255-F80164A5; Fri, 29 Dec 2017 04:53:19 -0500 Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1eUrLI-0000hG-9t; Fri, 29 Dec 2017 09:52:44 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eUrLG-0000gy-Up for openvpn-devel@lists.sourceforge.net; Fri, 29 Dec 2017 09:52:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding: 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=wc0sjAJ+hRvIpCB2V3qpt48p57JHGleO5AhrKR5O8u4=; b=YPZCct6fK3rykElqtWavwPSWPy 1zhdMqmbakdE2T0s6Z67XqzyUew4xx81s0UvsaPqesn6Bf8chUAnmooAYVdLIQ91SxYBDJq6ifvJS hWFCFpXOuuhrKTgpIV3XK6m4ebqTJaP779NkTrINbsgHchh0DUmdlrDRqNObxLwuv/RU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject: CC:To:From:Sender:Reply-To:Content-Transfer-Encoding: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=wc0sjAJ+hRvIpCB2V3qpt48p57JHGleO5AhrKR5O8u4=; b=gZ/D37Ge6birhEyZ3Yu4Ffp1co 0GWeGNYljalknAzcwO2mzSVcSIkXb0ux602xNhvnVkKe94P2qNbdXBxXJdwk4lpSRaXMJx0ceuhUZ wERaFNd7JyyEHb3oSdEvHg8867y7KElv49ZvtbjfR7IpKzO56xthyCQZIRj9JF3rhasc=; Received: from ns2.fox-it.com ([178.250.144.131]) by sfi-mx-2.v28.ch3.sourceforge.com with esmtps (TLSv1:ECDHE-RSA-AES256-SHA:256) (Exim 4.89) id 1eUrLF-0003CV-QE for openvpn-devel@lists.sourceforge.net; Fri, 29 Dec 2017 09:52:42 +0000 Received: from FOXDFT52.FOX.local (unknown [10.0.0.129]) by ns2.fox-it.com (Postfix) with ESMTPS id E26001AF767 for ; Fri, 29 Dec 2017 10:52:35 +0100 (CET) Received: from steffan-fox.fox.local (10.0.3.167) by FOXDFT52.FOX.local (10.0.0.129) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Fri, 29 Dec 2017 10:52:35 +0100 From: Steffan Karger To: Date: Fri, 29 Dec 2017 10:52:24 +0100 Message-ID: <1514541144-19407-1-git-send-email-steffan.karger@fox-it.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-ClientProxiedBy: FOXDFT52.FOX.local (10.0.0.129) To FOXDFT52.FOX.local (10.0.0.129) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1eUrLF-0003CV-QE Subject: [Openvpn-devel] [PATCH 2/5 v3] buffer_list_aggregate_separator(): update list size after aggregating 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-MS-Exchange-Organization-Network-Message-Id: 720ffa4e-7bfa-48f8-4095-08d54ea1fd99 X-MS-Exchange-Organization-AVStamp-Mailbox: SMEXzs^g;1387100;0;This mail has been scanned by Trend Micro ScanMail for Microsoft Exchange; X-MS-Exchange-Organization-AuthSource: MBX09D-ORD1.mex06.mlsrvr.com X-MS-Exchange-Organization-AuthAs: Anonymous MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: Inbox After aggregating a buffer_list, the size should be adjusted accordingly. Signed-off-by: Steffan Karger Acked-by: Antonio Quartulli --- v2: rebase on master v3: add spaces around '-' src/openvpn/buffer.c | 1 + tests/unit_tests/openvpn/test_buffer.c | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index e601a31..28ce8ca 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -1257,6 +1257,7 @@ buffer_list_aggregate_separator(struct buffer_list *bl, const size_t max, const e = next; } bl->head = f; + bl->size -= count - 1; f->next = more; if (!more) { diff --git a/tests/unit_tests/openvpn/test_buffer.c b/tests/unit_tests/openvpn/test_buffer.c index b4625bb..bddb30a 100644 --- a/tests/unit_tests/openvpn/test_buffer.c +++ b/tests/unit_tests/openvpn/test_buffer.c @@ -138,8 +138,7 @@ test_buffer_list_aggregate_separator_two(void **state) /* Aggregate the first two elements */ /* FIXME this exceeds the supplied max */ buffer_list_aggregate_separator(ctx->one_two_three, 4, testsep); - /* FIXME size does not get adjusted after aggregating */ - assert_int_equal(ctx->one_two_three->size, 3); + assert_int_equal(ctx->one_two_three->size, 2); struct buffer *buf = buffer_list_peek(ctx->one_two_three); assert_buf_equals_str(buf, teststr1 testsep teststr2 testsep); } @@ -151,8 +150,7 @@ test_buffer_list_aggregate_separator_all(void **state) /* Aggregate all */ buffer_list_aggregate_separator(ctx->one_two_three, 1<<16, testsep); - /* FIXME size does not get adjusted after aggregating */ - assert_int_equal(ctx->one_two_three->size, 3); + assert_int_equal(ctx->one_two_three->size, 1); struct buffer *buf = buffer_list_peek(ctx->one_two_three); assert_buf_equals_str(buf, teststr1 testsep teststr2 testsep teststr3 testsep); @@ -165,8 +163,7 @@ test_buffer_list_aggregate_separator_nosep(void **state) /* Aggregate all */ buffer_list_aggregate_separator(ctx->one_two_three, 1<<16, testnosep); - /* FIXME size does not get adjusted after aggregating */ - assert_int_equal(ctx->one_two_three->size, 3); + assert_int_equal(ctx->one_two_three->size, 1); struct buffer *buf = buffer_list_peek(ctx->one_two_three); assert_buf_equals_str(buf, teststr1 teststr2 teststr3); } @@ -179,8 +176,7 @@ test_buffer_list_aggregate_separator_zerolen(void **state) /* Aggregate all */ buffer_list_aggregate_separator(bl_zerolen, 1<<16, testnosep); - /* FIXME size does not get adjusted after aggregating */ - assert_int_equal(bl_zerolen->size, 2); + assert_int_equal(bl_zerolen->size, 1); struct buffer *buf = buffer_list_peek(bl_zerolen); assert_buf_equals_str(buf, ""); } @@ -193,8 +189,7 @@ test_buffer_list_aggregate_separator_emptybuffers(void **state) /* Aggregate all */ buffer_list_aggregate_separator(bl_emptybuffers, 1<<16, testnosep); - /* FIXME size does not get adjusted after aggregating */ - assert_int_equal(bl_emptybuffers->size, 2); + assert_int_equal(bl_emptybuffers->size, 1); struct buffer *buf = buffer_list_peek(bl_emptybuffers); assert_int_equal(BLEN(buf), 0); }