From patchwork Sun Nov 17 10:23:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 927 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.27.255.54]) by backend30.mail.ord1d.rsapps.net with LMTP id yPauI5i60V3AFgAAIUCqbw for ; Sun, 17 Nov 2019 16:24:40 -0500 Received: from proxy5.mail.iad3a.rsapps.net ([172.27.255.54]) by director11.mail.ord1d.rsapps.net with LMTP id wA/EIJi60V1BXAAAvGGmqA ; Sun, 17 Nov 2019 16:24:40 -0500 Received: from smtp32.gate.iad3a ([172.27.255.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy5.mail.iad3a.rsapps.net with LMTP id QLAxGpi60V2SFQAAhn5joQ ; Sun, 17 Nov 2019 16:24:40 -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: smtp32.gate.iad3a.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; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: a90c6560-0980-11ea-a09c-5254001741cc-1-1 Received: from [216.105.38.7] ([216.105.38.7:47340] helo=lists.sourceforge.net) by smtp32.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 03/C2-01252-79AB1DD5; Sun, 17 Nov 2019 16:24:39 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1iWS15-0002JP-CC; Sun, 17 Nov 2019 21:23:31 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1iWS14-0002J0-2y for openvpn-devel@lists.sourceforge.net; Sun, 17 Nov 2019 21:23:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type: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=DhMUZdpS524ppl+5535V3yvt04e8Bsh6XHyaOjI0gJk=; b=A35ibI+uj7R77xNJc85iJVntBG 3d3AXLJRWNqd0+9jEn3H/26WZufkD1L3HDUxvcN50OCSzwx7PsWpBgz+xKmoC93O/pS7sRv7DxJ9m SqTrZ4qZYlS8TOZW2YvEatp8KzUC6axYxKQJ3ZP+IntkDDsHwiMP5CyhLhwIb6aOpc9I=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type: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=DhMUZdpS524ppl+5535V3yvt04e8Bsh6XHyaOjI0gJk=; b=lI/9MFyIraRgjuVwKuz57c+dBf g45qinSFUz+TEOi22L/s/ROVhKBZyOf094QV7upKtgvQeHRsd1VNHYWxDAP+KIcim1ri3ZAH44Bcg /4OYrOllXp8E60FRrfpNiHAedrps5Tk1kcptkVIplh31dtG2nxpc0AiypEVxF8pbw6WQ=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1iWS10-009aSq-7W for openvpn-devel@lists.sourceforge.net; Sun, 17 Nov 2019 21:23:30 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1iWS0s-000BSZ-Nx for openvpn-devel@lists.sourceforge.net; Sun, 17 Nov 2019 22:23:18 +0100 Received: (nullmailer pid 13476 invoked by uid 10006); Sun, 17 Nov 2019 21:23:18 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Sun, 17 Nov 2019 22:23:18 +0100 Message-Id: <20191117212318.13428-2-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191117212318.13428-1-arne@rfc2549.org> References: <20191117181243.28919-1-arne@rfc2549.org> <20191117212318.13428-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: makefile.am] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1iWS10-009aSq-7W Subject: [Openvpn-devel] [PATCH 6/4] Add strsep compat function 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 Some operating system do not have the strsep function. Since this API is more "modern" (4.4BSD) than strtok, add it as compat function. At least Windows is missing strsep. FreeBSD, Linux, macOS and OpenSolaris should not need the compat function. Signed-off-by: Arne Schwabe --- configure.ac | 2 +- src/compat/Makefile.am | 1 + src/compat/compat-strsep.c | 61 ++++++++++++++++++++++++++++++++++++++ src/compat/compat.h | 4 +++ src/compat/compat.vcxproj | 3 +- 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/compat/compat-strsep.c diff --git a/configure.ac b/configure.ac index 807804e5..a9fd8e77 100644 --- a/configure.ac +++ b/configure.ac @@ -655,7 +655,7 @@ AC_CHECK_FUNCS([ \ ctime memset vsnprintf strdup \ setsid chdir putenv getpeername unlink \ chsize ftruncate execve getpeereid umask basename dirname access \ - epoll_create \ + epoll_create strsep \ ]) AC_CHECK_LIB( diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am index b51f661e..2e94e943 100644 --- a/src/compat/Makefile.am +++ b/src/compat/Makefile.am @@ -30,4 +30,5 @@ libcompat_la_SOURCES = \ compat-inet_ntop.c \ compat-inet_pton.c \ compat-lz4.c compat-lz4.h \ + compat-strsep.c \ compat-versionhelpers.h diff --git a/src/compat/compat-strsep.c b/src/compat/compat-strsep.c new file mode 100644 index 00000000..42ff6414 --- /dev/null +++ b/src/compat/compat-strsep.c @@ -0,0 +1,61 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2019 Arne Schwabe + * Copyright (C) 1992-2019 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif + +#ifndef HAVE_STRSEP +#include + +/* + * Modified version based on the glibc + */ +char * +strsep(char **stringp, const char *delim) +{ + char *begin, *end; + begin = *stringp; + if (begin == NULL) + { + return NULL; + } + /* Find the end of the token. */ + end = begin + strcspn(begin, delim); + if (*end) + { + /* Terminate the token and set *STRINGP past NUL character. */ + *end++ = '\0'; + *stringp = end; + } + else + { + /* No more delimiters; this is the last token. */ + *stringp = NULL; + } + return begin; +} +#endif diff --git a/src/compat/compat.h b/src/compat/compat.h index d5228989..592881df 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -70,4 +70,8 @@ int inet_pton(int af, const char *src, void *dst); #endif +#ifndef HAVE_STRSEP +char* strsep(char **stringp, const char *delim); +#endif + #endif /* COMPAT_H */ diff --git a/src/compat/compat.vcxproj b/src/compat/compat.vcxproj index e388008a..0c4c7b0f 100644 --- a/src/compat/compat.vcxproj +++ b/src/compat/compat.vcxproj @@ -102,6 +102,7 @@ + @@ -115,4 +116,4 @@ - \ No newline at end of file +