From patchwork Sun Feb 16 21:29:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 997 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id cCEyKFtPSl6VHgAAIUCqbw for ; Mon, 17 Feb 2020 03:31:23 -0500 Received: from proxy4.mail.ord1c.rsapps.net ([172.28.255.1]) by director11.mail.ord1d.rsapps.net with LMTP id 0KEaKFtPSl5ncwAAvGGmqA ; Mon, 17 Feb 2020 03:31:23 -0500 Received: from smtp28.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.ord1c.rsapps.net with LMTP id sJLRJ1tPSl7CdAAAjcXvpA ; Mon, 17 Feb 2020 03:31:23 -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: smtp28.gate.ord1c.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; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: e0fb0784-515f-11ea-b2be-a0369f1890f1-1-1 Received: from [216.105.38.7] ([216.105.38.7:58870] helo=lists.sourceforge.net) by smtp28.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id E6/38-20826-B5F4A4E5; Mon, 17 Feb 2020 03:31:23 -0500 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1j3bn8-0000BJ-Oo; Mon, 17 Feb 2020 08:30:10 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1j3bn7-0000BA-Qg for openvpn-devel@lists.sourceforge.net; Mon, 17 Feb 2020 08:30:09 +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:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5LRvNw5Y0yh/tp6AKNf4oRywYANnM7rH5U58QoJF3+Q=; b=PWVbaOhHUKur7+VXYLpswzv4lf 8+6RRGL7ceQRMGh+9oCKrBgESHqTCDHFVK/pSPhLLMcL0kaoG/mQdE+AOQGMJo2mzUs+3mKvgvC9f F7+/P6Ps3FBgrWSkeR2Sb89bA8DI2mpV+q1apys20u63x+Fld63fgL+akSyfjjTPdTZs=; 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:Sender:Reply-To:MIME-Version: Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5LRvNw5Y0yh/tp6AKNf4oRywYANnM7rH5U58QoJF3+Q=; b=MayKBEvYNXZUgCSrNOI7lB7I4+ wwtCXyHFwQo9QZdFLSR1/hwY9Xm57bINq7OunMGc22W+g3I7camqgQwz0sYvgeJCx+omWfSdQcNXP Mbjg9Q9iuV28Vguj2rXPUxluxsFuDcgppLlKtrJjMOOmXDlFP4LmaRiA+YDXKyyuV+PU=; Received: from mail-wm1-f67.google.com ([209.85.128.67]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1j3bn5-00FCXB-GQ for openvpn-devel@lists.sourceforge.net; Mon, 17 Feb 2020 08:30:09 +0000 Received: by mail-wm1-f67.google.com with SMTP id b17so17381052wmb.0 for ; Mon, 17 Feb 2020 00:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5LRvNw5Y0yh/tp6AKNf4oRywYANnM7rH5U58QoJF3+Q=; b=Fx/W6NjjOm8XvT8mtdo9G5jt/Vt57YxCHvwyz9oL7zVl+o7HHrYE0soZ0viD2m/kmY Mkp6BiZgUmyx1jn4yoUrQNS3cOEEj+KfGsKgxnw+Y+ZUNx9YhZaJIBt6VtRmuc9lXh6u O5dh3TgZ9JBp5UX55M9bsFJYuOPRJw5pE07nj12CbVFoVwMnKfuJR9oFgnQ4p4RauZyf qnMQi/J/2UtgKkbPwQ4ywSfPC20DdngGZypJY4SDXKMKDSg1rEhe86rJLtuYCUvX07aZ Pjqcwd0cwXfKjwDZZmr3Nch6dhQ+H0KHRRSw8ZWw+3+Fe3Rs0zovubNTakAiW/WmbaUR QL+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5LRvNw5Y0yh/tp6AKNf4oRywYANnM7rH5U58QoJF3+Q=; b=UoiHNYSEkd+BQvqaTFRsnc4q5VIOomH3kGeV9xF+YKqdhGvveMazBYTklQiSNuxao1 AdbAZ27LtHPJSsoUVaNWFtETimdIJd7oQAGa4Dff19dGQUQdtWpxVhI1noSUwNHh1DU1 eQYpaVJsFXhP+rnJKYsGq1ThFd1ElkbyYscWAh7k03dPdE8TjchbZpVLO+odNJdmH+7r NY28yeOsX75NC3Aek4JGw1XfydmZu5GeizbJ0PWuFN/QzlCGpa7m2zJky5DOOmcE9IJ5 c394jI4xsKDImjRxrCb6AGc7zSi6HcCZTQkZ2r9rTg2GSWO9fQQ6RuuVpxSsB28oGH4f GJlQ== X-Gm-Message-State: APjAAAWhZ9Rx2+sMonTkY16kyBoQhS6sL6uK8CfyP4IJ2xclPR71dGlW F/zkjRN9Dfa8plui5Y59p8jVxtJhuO0= X-Google-Smtp-Source: APXvYqwVPVRUNkYvEG8Jys8DStoA88m6aALU5mXwGjKPScKkHOn4EJZpPaiZvAIUDNKi7UjjzvJN+Q== X-Received: by 2002:a1c:ac46:: with SMTP id v67mr20338226wme.153.1581928200624; Mon, 17 Feb 2020 00:30:00 -0800 (PST) Received: from LAPTOP-4L3N7KFS.panoulu.local ([2a00:1d50:3:0:a11e:653e:991c:4e5f]) by smtp.gmail.com with ESMTPSA id b18sm20257706wru.50.2020.02.17.00.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 00:29:59 -0800 (PST) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Mon, 17 Feb 2020 10:29:41 +0200 Message-Id: <20200217082942.173-1-lstipakov@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.67 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lstipakov[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.67 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1j3bn5-00FCXB-GQ Subject: [Openvpn-devel] [PATCH] ssl.c: refactor tls_item_in_cipher_list() code 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: , Cc: Lev Stipakov MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov - remove unneeded _orig variable which stores pointer to tokenized string. Unlike strsep(), strtok() doesn't modify pointer itself, only string, so it is safe to call free() on that pointer. - "token" points to content inside tokenized string. It becomes dangling pointer after freeing that string. Check its value before free() call. Signed-off-by: Lev Stipakov --- src/openvpn/ssl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index e708fc93..8cba3a76 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -1918,7 +1918,6 @@ bool tls_item_in_cipher_list(const char *item, const char *list) { char *tmp_ciphers = string_alloc(list, NULL); - char *tmp_ciphers_orig = tmp_ciphers; const char *token = strtok(tmp_ciphers, ":"); while (token) @@ -1929,9 +1928,11 @@ tls_item_in_cipher_list(const char *item, const char *list) } token = strtok(NULL, ":"); } - free(tmp_ciphers_orig); - return token != NULL; + bool found = token != NULL; + free(tmp_ciphers); + + return found; } void