From patchwork Tue Aug 22 13:06:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3329 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c39e:b0:d7:3b0f:3938 with SMTP id fx30csp5101843dyb; Tue, 22 Aug 2023 06:08:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLMntrUrJwxWcHoI64oJ0qTce0mb29PS8GF5eU+bTamN1JOEqvzhz1tnevK0t0AjN67puI X-Received: by 2002:a05:6e02:1212:b0:348:8541:e59d with SMTP id a18-20020a056e02121200b003488541e59dmr8949273ilq.13.1692709686139; Tue, 22 Aug 2023 06:08:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692709686; cv=none; d=google.com; s=arc-20160816; b=P2hogSBz4KxJb3ZoOHvff4FrbbmccdcRWVJMcfVEXzok5A76r7C3Y3hNU2FXw7vehS IA2NtXePhoQO6+BVYsYdvO70wnTvuKC5bQF0MYnVFV2Bext2k2wag4Bmm2VKejK+AyY7 83au4ZEe97jTqzcisw9X8Nq/k3h57Yay+E0o1RAouc6Olr84D37jSI0lAo1Za7Qk+dRk P5T14WEljYh8FPrJX+I/RycmtOkRRHS1sCFqmmp55FekvyZymFCDcVQmuKsMWi5lH9fU 3Th2cXm3UHtARROeOCT9rsq8f634fedxd4hb3P/yQQumXW3M94CcaJiGNV5cM59aAJEr 3mxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:user-agent:mime-version :message-id:references:auto-submitted:cc:date:from:dkim-signature :dkim-signature:dkim-signature; bh=9uB3P3hZ7BxMLsjlL8VrdT8OeLnszwDgGj44zQZmP8E=; fh=ejqQk4evxSbcB4TOY987ChV164zUZaeCjiIZ6JGqg/c=; b=SH81Y/Zy4byktQ7jm5U+qOrhoOvIUkZ0VbmdOsI7GfP9Bf7lC8RNjtsGz8zU8DzfoC 7xx45w6bCh0HL+GrNuLWM+OilMN0KzJyHSLE0+Vuk/r7BHIeuU56oeUqCMCDQOFxS6Es jZn17mEI0MSTWTGT/MnvQoOjqlKTfLryyxL5a1Cj8HAEDwYFojxYqNVbm82I+OeS6S16 Z8SZFTRFURIbf8z5D/pQ5fymDiSjRmdsXV3B3vpTaK9oMsT8FQd9qW0r6BZLbHTECHZy KGKUPkmdvJWyM/rs2nxXaRt1IhSDXrBChxz8ZJ77+1z2qevqbKaF13FDTKkLCtTCstfm wVZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=dnFfUmRz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="eNgk/zE8"; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=BVlU58Gn; 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=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id m9-20020a654389000000b005653e3f6d58si8604490pgp.748.2023.08.22.06.08.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Aug 2023 06:08:06 -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=dnFfUmRz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="eNgk/zE8"; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=BVlU58Gn; 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=openvpn.net 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 1qYR6A-0005wl-Qa; Tue, 22 Aug 2023 13:07:07 +0000 Received: from [172.30.20.202] (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 1qYR69-0005wd-Od for openvpn-devel@lists.sourceforge.net; Tue, 22 Aug 2023 13:07:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:Date:From :Sender:To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0tGXkRw8MV3LIVi0iuvfdvgoGf36/00lCZQFrClZeRs=; b=dnFfUmRz5u+dzkJK5nY7qnmaGZ h3rF6LpGxBN5Cn49rkZ0/OiKyyKN4+HlvedQ6BMVg5d3ZeX7DUA3CZRI8JwNTqT4eOa+5TfTCLjp4 jTQFlFtkTqYPQL0ZwTKlmnGRxNmVr2RACSR+22mGsBWHKgyKX2rJ2Xk2adrtUoZiN+7I=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:Date:From:Sender:To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=0tGXkRw8MV3LIVi0iuvfdvgoGf36/00lCZQFrClZeRs=; b=e Ngk/zE8MTXFarNDm83PvXaKErPiWGy5HGz/pPhOmHc4RHKU+RuSgAqj08tzuAakR05JzO/542A6CW tpzOnfV7SjWzokACMNCy8dsXRsFSZnAxuNI8ARQ0ttUST+s8vOLw/Jd1/0SeV1V7r2zWJEZvRdYhU VaFPLggX+n8Yph94=; Received: from mail-wr1-f53.google.com ([209.85.221.53]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1qYR68-00CJ7J-Lw for openvpn-devel@lists.sourceforge.net; Tue, 22 Aug 2023 13:07:06 +0000 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-31c4d5bd69cso1901783f8f.3 for ; Tue, 22 Aug 2023 06:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1692709618; x=1693314418; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:date:from:from:to:cc :subject:date:message-id:reply-to; bh=0tGXkRw8MV3LIVi0iuvfdvgoGf36/00lCZQFrClZeRs=; b=BVlU58GnQj0KvLVYAGAwcSnI2mm1be2r+9D36+g8n3sFVMjvXY071nTq0ZIxwNKEgk P+9zExo49/RyRV5dFD7JVu0dqVbLCbEXjV1wSlEX02ybh6R8mdfiXuzFC6pOTTbgoN47 xaXlLignu4WHaCPGm2/iX3sKjCj5xik6+WgH0fln47/tTLorpRT5N5qp4CFzhoaz1lxU 37u0b+WFvbsrR37EDAzk5bLPTTJu3Af/0ZSLgmVgTjvwGuFcaSvxwG0kJkKB5ZGnCs0Q 4nnUVxljCdjTmTodtKEjsgDcv1s6V6SKn1DvXYRoRK22MFjSSSxteW6qwCx0mcC/iWf7 uvfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692709618; x=1693314418; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0tGXkRw8MV3LIVi0iuvfdvgoGf36/00lCZQFrClZeRs=; b=OUL8/Nb7e8WBKqO7oo7aRnvbEV+id/ee80emFBzF5YsoSdC/QLIem1gSLjiV/kDT9I nfvK6PoJVAljIy0D/M8n+zY+D0BBF2WEY7jvP23gCUc5oT/a0U1GzATGqKEVlul3PkEx 00h273GIhHGa5cxby7+GAWbzXQvPTkDHNSDh1uf5OGsNp7d0A4xjIKtIrCYdVb0dH7uI q8KOt7TCDfJhUv9gAA7NvgcyQREu45BeGRHvCWKfHz4TlQd/FrH7NQmAjJ/A6Pgv2j0n MI9BYuDA7/mx0ZlMl8GghjptQg+8mA74Kn88pG0AHeSqqzXr047cjqM6KUEeuBVLSddI PneQ== X-Gm-Message-State: AOJu0YyF4y4nz8H2pPGadC3120c5yPATvtFzZyj4xdpIawjqduRjxNOE PM3vtPTl5ThL7Mw2XBiK0QTX9NEQhe8aMc/9sWs= X-Received: by 2002:adf:fc12:0:b0:317:60f2:c08b with SMTP id i18-20020adffc12000000b0031760f2c08bmr7659097wrr.31.1692709617871; Tue, 22 Aug 2023 06:06:57 -0700 (PDT) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id b14-20020a5d4b8e000000b0031434c08bb7sm15802720wrt.105.2023.08.22.06.06.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 06:06:57 -0700 (PDT) From: "flichtenheld (Code Review)" X-Google-Original-From: "flichtenheld (Code Review)" X-Gerrit-PatchSet: 1 Date: Tue, 22 Aug 2023 13:06:56 +0000 Cc: openvpn-devel Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I052bebe720ddf26340827f25b94705945e470bfa X-Gerrit-Change-Number: 326 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 7e91bc748adb6272bfa25edd42133a4fe322d6cd References: Message-ID: MIME-Version: 1.0 User-Agent: Gerrit/3.8.0 X-Spam-Score: 1.0 (+) 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: flichtenheld has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/326?usp=email ) Change subject: Remove last uses of inet_ntoa Content analysis details: (1.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.53 listed in wl.mailspike.net] 1.2 MISSING_HEADERS Missing To: header 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.53 listed in list.dnswl.org] 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1qYR68-00CJ7J-Lw Subject: [Openvpn-devel] [S] Change in openvpn[master]: 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: , Reply-To: frank@lichtenheld.com, openvpn-devel@lists.sourceforge.net Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1774934751817740563?= X-GMAIL-MSGID: =?utf-8?q?1774934751817740563?= flichtenheld has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/326?usp=email ) Change subject: Remove last uses of inet_ntoa ...................................................................... Remove last uses of inet_ntoa 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 --- M src/openvpn/manage.c M src/openvpn/route.c M src/openvpn/socket.c 3 files changed, 17 insertions(+), 15 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/326/1 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);