From patchwork Mon Nov 30 17:25:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5823 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp13356557lad; Mon, 30 Nov 2026 09:26:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFyvQKA7l22nPNJSHBKHck+qIAHY9XX4CtV/XVW2X8l03QRv5yXlQdSkWLQbucH55hyUIw8Qxt8WZM=@openvpn.net X-Received: by 2002:a05:6820:a287:20b0:71b:c1aa:6ea5 with SMTP id 006d021491bc7-71bc1aa6f37mr862927eaf.57.1796059566130; Mon, 30 Nov 2026 09:26:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796059566; cv=none; d=google.com; s=arc-20260327; b=In3tj8H6148SL9hRcZ4+YR/qmpbbUdTdFT/3RM9qJ6KzrzsfpepsTDVPv7CjTGdmh8 U9Hx323liUvXBOcC/YrxRCSl2n29vFsEI8nR7UUyhe75wVulQOcHFbNADiiXKzMxD0hr eFG3yR7xGPVkY92xyKwmjQHRuSZz8+0NAMKKWfRGCUoH7ShovFCHiasCMJcIOv9BfoOu owPM8w4tjbNhD4LRPoiDtBF+Yb8gSErcWE/b+stGm+u07lxu+uFqV2AyqKt+zZwBQQAE gR54Fj8+7JUadTclRZ6XJtOSV/QKHH3fR5S832Lfo44SCz9q108gmAYFP2E44NeMR+XX 290w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=Gc0tEOoUEwy9fneLhNTu6Oa2/M1fj7LRvrp5pi/WpCY=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=DwIGHQ5LCBMOD0iCtEu5uUl49Z8gy4vqzpRnhHIot3hCHcDV/k1sTMeD4LOHuGZBBw +qT3f4aqBCUjUqitBFbuBCs6z4kfU6Rg/FYdJeRlda0Mz1rFY51bb98jW5Sc7tYwkGxV n+h7Rr7/QxnAiGygxpb7SJcBgQFJvFPCpxhz/KNbVByqeNi1LmrerAcRiElCQlo/X6j3 Zj+7NyMKBb/GYIQrribFV2sES3ceGWYXWeUcl8VEa5wi6Gi/rrl9xXl8ZrHpvBaOfaq7 bCbZBxWb3lptc0/oDaQtqXe6UHNoxQa7Hq/oQY0EJPxEzWGe1qml5pEIA7T24FM34jVH MCMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=ZQgG59nh; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=UdT2JFkH; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VZDRseD+; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 46e09a7af769-863168e2f19si51446554a34.68.2026.11.30.09.26.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2026 09:26:06 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=ZQgG59nh; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=UdT2JFkH; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VZDRseD+; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=Gc0tEOoUEwy9fneLhNTu6Oa2/M1fj7LRvrp5pi/WpCY=; b=ZQgG59nh8sId0s C6X7UWz3Gpxu3970ZuQKiWus/2p6uxvhQ+QAHy4aWgX7QhQ6dJe7MKSEOq+rnSDaNqsdQLCmWU9wt D6mMwvrnNyNkMIjlinrtJjFyNlVeq2ysOGT055VSACzruZFxEETtYOVPlGLbyXQF9O+rYR3ysqbiK /fo=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xY58d-000000003E3-2ELs; Mon, 30 Nov 2026 17:26:03 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xY58b-000000003Dk-2FsY for openvpn-devel@lists.sourceforge.net; Mon, 30 Nov 2026 17:26:01 +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-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=S5tDmZSFFWeNVuqJ9LPXykshTJBx+rTOrePzykjeO7o=; b=UdT2JFkH95srA9xSHVeEI10qaM aOA5bXWGElYl3IH34Fq1L8A4orkmK+dkkmk1X1nsxn3k6/cDILyldIaRawpoetaQ+FEQcaQlhwxO2 9YE032txwg4cZxcdmIgDj32DWGbOGwlHwnaScoBXGbhwhfoEYRdmVm9D6adjBeJaATo4=; 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-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=S5tDmZSFFWeNVuqJ9LPXykshTJBx+rTOrePzykjeO7o=; b=VZDRseD+8N2a+Ov29bSiALCmyM ceAQIhY68BDZVADjMPcV8bJ64AhvWENW3VYCr8Czh73vYtisB8euKqqUHeHwFeymDbBd64gYOOWah lBP1KJTrXIhMyZPnynZA5fwAtzFp7t8+zKRIh1oruaV6JGpBxbKaY77JHCBYIECPWRHk=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xY58Z-000000005Xn-3MU5 for openvpn-devel@lists.sourceforge.net; Mon, 30 Nov 2026 17:26:01 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6AUHPqB7029884 for ; Mon, 30 Nov 2026 18:25:52 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6AUHPqqH029883 for openvpn-devel@lists.sourceforge.net; Mon, 30 Nov 2026 18:25:52 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 30 Nov 2026 18:25:46 +0100 Message-ID: <20261130172552.29874-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", 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: From: Razvan Cojocaru The text following the last occurrence of the search string was never copied, so a name/value like "USERNAME@example.com" was answered with the bare username. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xY58Z-000000005Xn-3MU5 Subject: [Openvpn-devel] [PATCH v1] auth-pam: keep the text after the last match in searchandreplace() 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 X-GMAIL-THRID: 1883304955600744082 X-GMAIL-MSGID: 1883304955600744082 From: Razvan Cojocaru The text following the last occurrence of the search string was never copied, so a name/value like "USERNAME@example.com" was answered with the bare username. Copy the rest of the string after the loop and add a test for it. Change-Id: I9b0ea680539846b287d5a5b77f981437f7dc7835 Signed-off-by: Razvan Cojocaru Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2374 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2374 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/plugins/auth-pam/utils.c b/src/plugins/auth-pam/utils.c index 01cc4de..22c4eea 100644 --- a/src/plugins/auth-pam/utils.c +++ b/src/plugins/auth-pam/utils.c @@ -88,6 +88,7 @@ searching = scratch + searchforlen; scratch = strstr(searching, searchfor); } + memcpy(target, searching, strlen(searching)); return strdup(temp); } diff --git a/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c b/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c index 89f0642..cee8ebc 100644 --- a/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c +++ b/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c @@ -64,6 +64,17 @@ } static void +replace_with_trailing_text__trailing_text_is_kept(void **state) +{ + char *replaced = searchandreplace("aXbXcd", "X", "YY"); + + assert_non_null(replaced); + assert_string_equal("aYYbYYcd", replaced); + + free(replaced); +} + +static void pattern_not_found__returns_original(void **state) { char *replaced = searchandreplace("abc", "X", "Y"); @@ -84,6 +95,7 @@ cmocka_unit_test(replace_single_char__one_time__match_is_replaced), cmocka_unit_test(replace_single_char__multiple_times__match_all_matches_are_replaced), cmocka_unit_test(replace_longer_text__multiple_times__match_all_matches_are_replaced), + cmocka_unit_test(replace_with_trailing_text__trailing_text_is_kept), cmocka_unit_test(pattern_not_found__returns_original), };