From patchwork Sun Oct 15 08:05:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 33 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director5.mail.ord1d.rsapps.net ([172.30.157.12]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id gYi+Abax41nYFgAAgoeIoA for ; Sun, 15 Oct 2017 15:06:30 -0400 Received: from proxy4.mail.ord1d.rsapps.net ([172.30.157.21]) by director5.mail.ord1d.rsapps.net (Dovecot) with LMTP id OfSuAbax41lXGQAAsdCWiw ; Sun, 15 Oct 2017 15:06:30 -0400 Received: from smtp21.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.ord1d.rsapps.net (Dovecot) with LMTP id aaj5D/Cw41kAEQAAiYrejw ; Sun, 15 Oct 2017 15:06:30 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-MessageSniffer-Scan-Result: 0 X-MessageSniffer-Rules: 0-298-994-1197-w 0-298-994-1561-w 0-298-0-7239-f X-CMAE-Scan-Result: 0 X-CNFS-Analysis: v=2.2 cv=a+JyzgaF c=1 sm=1 tr=0 a=Q8DxjiC8O3VT/NpP1XjEZQ==:117 a=Q8DxjiC8O3VT/NpP1XjEZQ==:17 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=yLqVZIfK32oA:10 a=02M-m0pO-4AA:10 a=WiVod9pSvdkA:10 a=pGLkceISAAAA:8 a=9sSjY8p1AAAA:8 a=P_JWiMecAAAA:8 a=FP58Ms26AAAA:8 a=ka9YgRoAURTOWpje7v8A:9 a=CjuIK1q_8ugA:10 a=-FEs8UIgK8oA:10 a=NWVoK91CQyQA:10 a=ub54wNWiXv_DzeFsgEJW:22 a=D0-HAvA3Hk9NMREbgwuX:22 X-Orig-To: justin@openvpn.net X-Originating-Ip: [216.34.181.88] Authentication-Results: smtp21.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; 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=fail (p=none; dis=none) header.from=gmail.com X-Classification-ID: f3395354-b1db-11e7-aa00-525400a98691-1-1 Received: from [216.34.181.88] ([216.34.181.88:21114] helo=lists.sourceforge.net) by smtp21.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 73/D6-10608-5B1B3E95; Sun, 15 Oct 2017 15:06:29 -0400 Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1e3oEd-0005lG-0z; Sun, 15 Oct 2017 19:06:03 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.89) (envelope-from ) id 1e3oEc-0005l8-Es for openvpn-devel@lists.sourceforge.net; Sun, 15 Oct 2017 19:06:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:Cc:To:From; bh=Pft0GqZm83FvMXAlbNXQ7KZHdOQR/g8Eev4vor6S//E=; b=ijVdf0rRLv4G05r/55dXhP8RBAMGQfZM1YPxI9zao1v4TpXH+eLWOd1QbK4jyCaLRyiwDAKoX0vbvLWgM9IDvp6JvBJbvQSTvc42eQyVBS1taUWIz860TUlB5RpBBZbe2OW0lUlAfxGMFGBmDC+bUKwFvgkSn8AL5cMuHs1RFbQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x; h=Message-Id:Date:Subject:Cc:To:From; bh=Pft0GqZm83FvMXAlbNXQ7KZHdOQR/g8Eev4vor6S//E=; b=PuTSmWShUZA/xC1HNk3vPwR5ZOMCe0gGZHazKuqw7f3MT0J5Dpf9ihg/4X1vvxE0qqkLzpojSlcbSw7vomEdV7pEX3ZsslcqbI0HB2iWr4ZQbKqdYT9F6aTa0TtfNFeQDq4kOHuXrhCZ+JgQD/taUX8qbE5Ij/foGrLlxz1Kx0s=; X-ACL-Warn: Received: from scala.nanotech.utoronto.ca ([128.100.226.29]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1e3oEb-0008Qr-Nc for openvpn-devel@lists.sourceforge.net; Sun, 15 Oct 2017 19:06:02 +0000 Received: by scala.nanotech.utoronto.ca (Postfix, from userid 1000) id E3F30838BD; Sun, 15 Oct 2017 15:05:21 -0400 (EDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Sun, 15 Oct 2017 15:05:15 -0400 Message-Id: <1508094315-466-1-git-send-email-selva.nair@gmail.com> X-Mailer: git-send-email 2.6.2 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (selva.nair[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list X-Headers-End: 1e3oEb-0008Qr-Nc Subject: [Openvpn-devel] [PATCH] Fix missing check for return value of malloc'd buffer 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Selva Nair - Use utf8to16 from common.c for utf8 to wide conversion and check its return value Signed-off-by: Selva Nair --- src/openvpnserv/interactive.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 3f98217..f3be113 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -547,15 +547,17 @@ static DWORD InterfaceLuid(const char *iface_name, PNET_LUID luid) { NETIO_STATUS status; - LPWSTR wide_name; - int n; - - n = MultiByteToWideChar(CP_UTF8, 0, iface_name, -1, NULL, 0); - wide_name = malloc(n * sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, iface_name, -1, wide_name, n); - status = ConvertInterfaceAliasToLuid(wide_name, luid); - free(wide_name); + LPWSTR wide_name = utf8to16(iface_name); + if (wide_name) + { + status = ConvertInterfaceAliasToLuid(wide_name, luid); + free(wide_name); + } + else + { + status = ERROR_OUTOFMEMORY; + } return status; }