From patchwork Sun Oct 8 10:34:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3378 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:b412:b0:f2:62eb:61c1 with SMTP id dj18csp1440289dyb; Sun, 8 Oct 2023 03:35:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3oHgS25Gq4UPrKTM0urGpxBOLBEJe2TLZPTJ0eZ+DKLHNuReGKc3aA6G5g/qu33jZeMC7 X-Received: by 2002:a05:6a21:197:b0:14e:2c56:7b02 with SMTP id le23-20020a056a21019700b0014e2c567b02mr16077452pzb.0.1696761301959; Sun, 08 Oct 2023 03:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696761301; cv=none; d=google.com; s=arc-20160816; b=tcqpBrPQpK7Eut+VzCG6ee/32v/gsc7g5choX+En3spvlV+qLVhZG6GhS5IMpfvmZo Nzr8qqD3RUrFMwEsy+uVfR5IfqzCd7TNQyJqJCpg+5B8Xwdt7uVyZ5DwqszrKmP1eNmT PBJqwWmZxTv/IGBaAFMcvGwZzC7qwidRZfHr+mdPhMCJmHkqWwncWGdlXb3PpLJd3xbQ fPsd//SgiOHJun7XL8+ZslcNJ7uAWcYPZ9+8vWqzvnFzL8QloiHjSXU6w1V1SBkQXOs1 IcdWtMEEVdlZ8dV17eAE4T2I5s1kD+BGcIr8Sbar65ZmQf4tEPnigHGa4R1wtJNDbYQO woPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:cc: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=T5dNTZSFjX/YIRBNB/ENpdUh1UYkfwQRUM37Hzz2p5c=; fh=CfxSpwd5kfiMJoL3kcov7PTxVKT7pGe/79idnx9XlBs=; b=MQ0xx65+RRTKHT4cmarWmEapYfvIz3rdjeeim81a1/7nYhSUAebOg753xMrTqMFBPW LTe+JVZSxVZmurypBjk3V+yhp9bwmUNzKxKikTvjAxomDQo0Mb24DgrMhcy2sYrPv+Dn ABaNgE+D+oUZQ5UxEK+i8O9PW6IEsLHGCgAgih5mtoWBNDzfS7zDuKK8t7ToITZYYVLC rb6C9VAt7pKmyiXyH4x8RpZxIl61xYmyQdJaTuIrH69/vsisdrppg6/OdeN2AUS94Gz6 AtpEu6Ymyr3rTFjSkzZTzmXG0q7pgOAzLZf0VRJEAbY+lTRdFmpaCD39sD5no0OiwoOF 05ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iC2iI6wm; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mcF5V5r3; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=Nv5la+Cr; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id e9-20020a056a00162900b00690fb3c5cecsi5041109pfc.16.2023.10.08.03.35.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Oct 2023 03:35:01 -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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iC2iI6wm; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mcF5V5r3; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=Nv5la+Cr; 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 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.95) (envelope-from ) id 1qpR7M-0000Dr-DB; Sun, 08 Oct 2023 10:34:36 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qpR7J-0000Dh-PH for openvpn-devel@lists.sourceforge.net; Sun, 08 Oct 2023 10:34:35 +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:Cc:To:From:Sender:Reply-To: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=spWtKDS1TYdRGQ3wzRX0Iw2pR34XIDjHUKhnxPlCbX0=; b=iC2iI6wmhrHj1Tor4JlVLF7yzs rZ/i2XgUMKeXuoLYPosSgGSVvuvIupD5/dfpdupgqBuzH762PnM/tkR/CIV9GoDmNtFDe4vZI2dzI v2N+oYZ1LnEB6v2Fl6DPmVugafCK81rQ1EgyoFyD/dNI549ZiB48tOgpB9kt8GouBBKY=; 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:Cc:To:From:Sender:Reply-To: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=spWtKDS1TYdRGQ3wzRX0Iw2pR34XIDjHUKhnxPlCbX0=; b=mcF5V5r3gCSkhRpdZ22aSGDZd1 m8f9Prqur6gWMmtbcKK7e5K/0bb3b6DS/H1Xdaw607UTSUAV58W+FqOSkPoPpu6VwRDU2A0/Ass0K qiZRx/X5AiSiVwCY7sF8RWkCZB8RYrcK4GczNlpIVWfGM/ax8mHVtgnKe+Yh+6/NjAsU=; Received: from mout-p-201.mailbox.org ([80.241.56.171]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1qpR7F-0008UY-1M for openvpn-devel@lists.sourceforge.net; Sun, 08 Oct 2023 10:34:33 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4S3JSB1l8jz9sb6; Sun, 8 Oct 2023 12:34:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1696761258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=spWtKDS1TYdRGQ3wzRX0Iw2pR34XIDjHUKhnxPlCbX0=; b=Nv5la+CrMn8MMBwFrsagibrAzzW7VZZWTkMYruutZSES1WMwAksYF7cueGLdiDMUcnIAAW NE9WbRKRSY/xTfWjpCOZ7EuS39+7lGhWzDUP9vdJAZPVF2A/Anthi8wgwq2jL7PNNocKOs 7xBXHhEQvXZOMTzAKpBiW18NYY9vl+NccGAAjv+MADxy2AvXoMzjModLB5yIT1m2q4BCll a1FO+95ePikYeM2u5ekDozVq631UnrU+LOhQf4TylTHLFW/uBflS9F+bwYFC0laAbdxUfc 4kVBBD18sYmAs44PhPB2c0ANuU0EDKS+dwco/l+lVmasj45cW9dRZMswLP8D/Q== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Sun, 8 Oct 2023 12:34:15 +0200 Message-Id: <20231008103415.19625-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4S3JSB1l8jz9sb6 X-Spam-Score: -1.9 (-) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", 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: inet_ntoa is officially deprecated and in some places its use already causes warnings (e.g. Fedora submissions). Since we mostly use inet_ntop already, just convert the remaining usages to that. Change-Id: I052bebe720ddf26340827f25b94705945e470bfa Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe --- Content analysis details: (-1.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.171 listed in list.dnswl.org] -1.0 RCVD_IN_MSPIKE_H5 RBL: Excellent reputation (+5) [80.241.56.171 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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 -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1qpR7F-0008UY-1M Subject: [Openvpn-devel] [PATCH] Remove last uses of inet_ntoa 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: Arne Schwabe Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1779183178819555780?= X-GMAIL-MSGID: =?utf-8?q?1779183178819555780?= inet_ntoa is officially deprecated and in some places its use already causes warnings (e.g. Fedora submissions). Since we mostly use inet_ntop already, just convert the remaining usages to that. Change-Id: I052bebe720ddf26340827f25b94705945e470bfa Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe --- 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/+/326 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Arne Schwabe diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 739ed40..feb62b2 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -3058,9 +3058,11 @@ /* listen on our local TUN/TAP IP address */ struct in_addr ia; int ret; + char buf[INET_ADDRSTRLEN]; ia.s_addr = htonl(tun_local_ip); - ret = openvpn_getaddrinfo(GETADDR_PASSIVE, inet_ntoa(ia), NULL, 0, NULL, + inet_ntop(AF_INET, &ia, buf, sizeof(buf)); + ret = openvpn_getaddrinfo(GETADDR_PASSIVE, buf, NULL, 0, NULL, AF_INET, &man->settings.local); ASSERT(ret==0); man_connection_init(man); diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 9212186..ff64938 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -342,7 +342,9 @@ goto fail; } special.s_addr = htonl(special.s_addr); - ret = openvpn_getaddrinfo(0, inet_ntoa(special), NULL, 0, NULL, + char buf[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &special, buf, sizeof(buf)); + ret = openvpn_getaddrinfo(0, buf, NULL, 0, NULL, AF_INET, network_list); } else diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 501e023..903f98b 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2901,16 +2901,16 @@ print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc) { struct in_addr ia; - struct buffer out = alloc_buf_gc(64, gc); + char *out = gc_malloc(INET_ADDRSTRLEN, true, gc); if (addr || !(flags & IA_EMPTY_IF_UNDEF)) { CLEAR(ia); ia.s_addr = (flags & IA_NET_ORDER) ? addr : htonl(addr); - buf_printf(&out, "%s", inet_ntoa(ia)); + inet_ntop(AF_INET, &ia, out, INET_ADDRSTRLEN); } - return BSTR(&out); + return out; } /* @@ -2920,16 +2920,14 @@ const char * print_in6_addr(struct in6_addr a6, unsigned int flags, struct gc_arena *gc) { - struct buffer out = alloc_buf_gc(64, gc); - char tmp_out_buf[64]; /* inet_ntop wants pointer to buffer */ + char *out = gc_malloc(INET6_ADDRSTRLEN, true, gc); if (memcmp(&a6, &in6addr_any, sizeof(a6)) != 0 || !(flags & IA_EMPTY_IF_UNDEF)) { - inet_ntop(AF_INET6, &a6, tmp_out_buf, sizeof(tmp_out_buf)-1); - buf_printf(&out, "%s", tmp_out_buf ); + inet_ntop(AF_INET6, &a6, out, INET6_ADDRSTRLEN); } - return BSTR(&out); + return out; } /* @@ -2978,7 +2976,7 @@ { char name_buf[256]; - char buf[128]; + char buf[INET6_ADDRSTRLEN]; switch (addr->addr.sa.sa_family) { case AF_INET: @@ -2991,7 +2989,8 @@ openvpn_snprintf(name_buf, sizeof(name_buf), "%s", name_prefix); } - setenv_str(es, name_buf, inet_ntoa(addr->addr.in4.sin_addr)); + inet_ntop(AF_INET, &addr->addr.in4.sin_addr, buf, sizeof(buf)); + setenv_str(es, name_buf, buf); if ((flags & SA_IP_PORT) && addr->addr.in4.sin_port) { @@ -3007,13 +3006,12 @@ memcpy(&ia.s_addr, &addr->addr.in6.sin6_addr.s6_addr[12], sizeof(ia.s_addr)); openvpn_snprintf(name_buf, sizeof(name_buf), "%s_ip", name_prefix); - openvpn_snprintf(buf, sizeof(buf), "%s", inet_ntoa(ia) ); + inet_ntop(AF_INET, &ia, buf, sizeof(buf)); } else { openvpn_snprintf(name_buf, sizeof(name_buf), "%s_ip6", name_prefix); - getnameinfo(&addr->addr.sa, sizeof(struct sockaddr_in6), - buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + inet_ntop(AF_INET6, &addr->addr.in6.sin6_addr, buf, sizeof(buf)); } setenv_str(es, name_buf, buf);