From patchwork Thu Oct 30 19:47:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4554 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:2f13:b0:72f:f16c:e055 with SMTP id sa19csp1160946mab; Thu, 30 Oct 2025 12:47:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXrw8h9GJJw9m+W7QIGqCC/ns/9Eu9dNyVgyLZvLsNemWtrIS50cbVZmm76vCeDkXAYotjF3AHd9/A=@openvpn.net X-Google-Smtp-Source: AGHT+IEKVE7auBo6ybsA+5SRKm0IMn9lqVko7xByDOli7Y2xkxQNmNXQ5k1x3PM3RXBUKljXz5sn X-Received: by 2002:a05:6808:6f88:b0:43b:2995:58b4 with SMTP id 5614622812f47-44f95edef63mr389554b6e.28.1761853672515; Thu, 30 Oct 2025 12:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1761853672; cv=none; d=google.com; s=arc-20240605; b=edyRLs/h4N3P8Ch7GkYcIfoEvj53/eg2K46Qu9/QyQDZT8ZjzBkTZxWDLCyZVCJYiN 7UIWRIjsaEGm9NK1AyYWW2zD67hP1FUlfbNW0ZKqnJb2w0vZYbZcMK6msdd87BQojXt2 WMyYZyD2vDxCsEcwjXeu7uCLsmQn5krDOJ3kJcxotw6eys/tcF07M4wCmTF4dZNG8+CE 1klaD6CDRlCKdhjX2vejNfr+YQ55hOBLjCiLwcoNR+lqo38Mpia2eygVNq8J3qmJDuZQ 9sILG/OHAL9tp5xYlh4fxfK6onJw/H9s335VuO3OJdAhmDur9cCYUpImu5ge9oN33aht RmOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=YM/gd/w8i6zIUBC76gQkgl/SCPzU8h7NRSuQwinBkbk=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=Fdwhmg6tnTPThUBy4g5hMAEkYjZJ3QSaTDxA6mmkM2gYHDpIL4sV1a4bcjf5aNwrTF CeI7C/qcAjuQnqlEr+J6cXC52b8g70d7TC2FKmQIZuaN136RGG2kLVn00iQuiYbjXP6i 7yyCuVNU7KxR9C2TrhphkKGulA20izlJk5EpXG57naeyrSbwMYQ3sgAremI+t+yI4WDx PgVF43poYr4xPrlWpbXY1q4KF37sF33o73GyykFMv8iEoS40hVp4dl7hz5x3gMu9pqkP VMpIAFfZfnW9H1uKsgOac7YbQksMzH5ntFopEuzbNrDebHKjFHC4lJ277oiRMJ+9ZZtl jjtw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=We4WWwAC; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=LIvPK5ud; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=KOhXMi2E; 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 5614622812f47-44da528c791si4532997b6e.78.2025.10.30.12.47.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Oct 2025 12:47:52 -0700 (PDT) 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=We4WWwAC; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=LIvPK5ud; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=KOhXMi2E; 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-Owner; bh=YM/gd/w8i6zIUBC76gQkgl/SCPzU8h7NRSuQwinBkbk=; b=We4WWwACF+9MSsmDy2FWVC2hwP ohHrcpW5q9nnuAfzIxvez10b6lZBB68wpHIHGRiXc7red3wso5BgPYlcqbLmaKKswYZcrOIu4/IzT 7rEvhb21AWbg86Tien3/sBAUoAIMoWKeltlBT/KoYYPmaxNZEX8uG0T1zN0ZHVLB72lw=; 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.95) (envelope-from ) id 1vEYcg-000240-N6; Thu, 30 Oct 2025 19:47:50 +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.95) (envelope-from ) id 1vEYcf-00023u-Ix for openvpn-devel@lists.sourceforge.net; Thu, 30 Oct 2025 19:47:49 +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=k/3TCmITk4ckPdq6uSXhJM20QGx8Wmr1t7iMpSjswPw=; b=LIvPK5udWemBx+D5tUuYyVniYq b3qCUu6wgN2kbo3bJQCVUfRaeVgvKrKUtJhQ6nk2V75I4X/Rw5/95ZgKiFsjmJhrWaJDJB0El8rC6 RJlP/eUkf1Fnmd/Z8JeV++0EdFyGKXySOf6/BuYpg9RoZOWdqLGpHeOITuAlCXvCH7lo=; 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=k/3TCmITk4ckPdq6uSXhJM20QGx8Wmr1t7iMpSjswPw=; b=KOhXMi2Em4iY+Id9fF350EO/Ii vRlSPfCmYaXuki3WLgRr8KKS2BRWxnWAZcxEi9/HMSx4J+bLtYFo3zC9j8+S6l+CE0xb+CXhVzsAP I8LdqtZsdzo0lb/CfpmfoORaXhH/BBvXOHYCz7GdwEn4HvsMaAXzzgLPTThOqp2fhWMw=; Received: from [193.149.48.134] (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.95) id 1vEYce-0001bL-Kg for openvpn-devel@lists.sourceforge.net; Thu, 30 Oct 2025 19:47:49 +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 59UJlbTS002176 for ; Thu, 30 Oct 2025 20:47:37 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 59UJlbpV002175 for openvpn-devel@lists.sourceforge.net; Thu, 30 Oct 2025 20:47:37 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 30 Oct 2025 20:47:31 +0100 Message-ID: <20251030194736.2151-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.1 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: Heiko Hund If the first call to MultiByteToWideChar returns 0, something must have failed, because it returns the required buffer size including the terminating zero. When it does return 0, just return NULL and [...] 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: 1vEYce-0001bL-Kg Subject: [Openvpn-devel] [PATCH v1] iservice: check return value of MultiByteToWideChar 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: =?utf-8?q?1847437476919820480?= X-GMAIL-MSGID: =?utf-8?q?1847437476919820480?= From: Heiko Hund If the first call to MultiByteToWideChar returns 0, something must have failed, because it returns the required buffer size including the terminating zero. When it does return 0, just return NULL and indicate that the call to utf8to16(_size) failed. Found by ZeroPath. Reported-By: Joshua Rogers Change-Id: I92804da010bab36cd0326759c04f955f2bda74de Signed-off-by: Heiko Hund Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306 --- 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/+/1306 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c index e975cc7..d25d9c0 100644 --- a/src/openvpnserv/common.c +++ b/src/openvpnserv/common.c @@ -276,6 +276,10 @@ utf8to16_size(const char *utf8, int size) { int n = MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0); + if (n == 0) + { + return NULL; + } wchar_t *utf16 = malloc(n * sizeof(wchar_t)); if (!utf16) {