| Message ID | 20230210133159.1336-1-lstipakov@gmail.com |
|---|---|
| State | Accepted |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net>
Delivered-To: patchwork@openvpn.net
Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp1274060dyk;
Fri, 10 Feb 2023 05:33:20 -0800 (PST)
X-Google-Smtp-Source:
AK7set9uWyRzTUvfEi5C+uJmOsp7oXiNpnqu2nrVXhtMFazY2Wc0zhvc2YOlUVzOMWXHD9Q20FDM
X-Received: by 2002:a17:90a:2:b0:230:c41b:4d8d with SMTP id
2-20020a17090a000200b00230c41b4d8dmr388710pja.16.1676036000387;
Fri, 10 Feb 2023 05:33:20 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1676036000; cv=none;
d=google.com; s=arc-20160816;
b=SuMVLkOBSBIKbJ11M6uVdXlyHlAftSwaS5LvBmh9SEAglO8pOj+FNOi3FjgGK09Uij
Iy3mafaOXYMcMMrO88U1uDn/O352VpXbILvXOEo0yyTl8C/+scXkMSOlQl6Hc14fuhT3
1BSKMmjHFbGFC0oNeJwthYEO2iaMy1fFxVfUKwn+bgAFZyiEdTMTidzj6IqzMQZZVsep
4wadTxq/hSr2PaHkRsSFI1PGZeHKJQT6WU5nCasLm5cUjC52ZLNJmLg/pIRTfyu7glu7
Ta9FRGKpPJB/yOeuCCvFgFMBHX00i9V2nhjSFwy7SX9AHO3VY8fiXr24rMbh4pGaXxp/
xVBw==
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:message-id:date:to:from:dkim-signature:dkim-signature
:dkim-signature;
bh=EqJdhzLdVlf6B+crtq1w6Va1mZ/QnT7l3YR/kJor7ak=;
b=q7FzUvrvyRyZVVEZcm086m0L8nz7Uaip1LGfZ2sPkVmD7kYBaoqac0I0ezehjOiayh
4PAtfbakgksiK0eHuIae0e2N9GSlSUjeNYaDNDnApP+Zr7aGwVt8fFhRaCwUOeg7f+Wq
FxNn6ZJjrh1HCJhXCp8Q4+R5m4xdyDAOk3h38tPXRJvWXgFkSLJTycRg/LXEByl6R8Si
Ocv/65JFyJiKqXqL8VNH6yd2rF4fyWy1+b4qQmsT6EKxNB3xHmiYNGdg+s5n2h4R/zaR
vhlA1ZsgwI1VVIRo+w3JV9R8/+iPzfnMiUfjk3hlFziHPNM097a68JC9ZwXatzwSgvj6
Ee5w==
ARC-Authentication-Results: i=1; mx.google.com;
dkim=neutral (body hash did not verify) header.i=@sourceforge.net
header.s=x header.b=ZOSBswBy;
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=iG+u00A9;
dkim=neutral (body hash did not verify) header.i=@gmail.com
header.s=20210112 header.b=hM3oUpCw;
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=QUARANTINE dis=NONE) header.from=gmail.com
Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7])
by mx.google.com with ESMTPS id
bk16-20020a17090b081000b0022c72095ea8si4733479pjb.99.2023.02.10.05.33.20
(version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
Fri, 10 Feb 2023 05:33:20 -0800 (PST)
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=ZOSBswBy;
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=iG+u00A9;
dkim=neutral (body hash did not verify) header.i=@gmail.com
header.s=20210112 header.b=hM3oUpCw;
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=QUARANTINE dis=NONE) header.from=gmail.com
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 <openvpn-devel-bounces@lists.sourceforge.net>)
id 1pQTVt-0000oA-O3;
Fri, 10 Feb 2023 13:32:28 +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 <lstipakov@gmail.com>) id 1pQTVs-0000o3-8f
for openvpn-devel@lists.sourceforge.net;
Fri, 10 Feb 2023 13:32:27 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
List-Subscribe:List-Post:List-Owner:List-Archive;
bh=SSuyvT/PSd4Qxdi/yizfF6ZWaGvQcAfWlh9Bs63Ddrg=; b=ZOSBswBySQiBHEskY0ANqTORse
cTqDDS9McwFBZFzOQnD3xjKLTTr/pVBqueHkHkuM13eCUj3hxYrXVAnWRbFPdXlIuYFF3nIf5CIia
NsKU2SRp4YHzsx800xhJ50q7C/ZrOMeI6w80Z+MMQ3/TIPuPq5CLXGevSgOM+C00teYY=;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x
;
h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To:
References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:
List-Owner:List-Archive; bh=SSuyvT/PSd4Qxdi/yizfF6ZWaGvQcAfWlh9Bs63Ddrg=; b=i
G+u00A9v0Ohu0aBs/8F73mPOrtHGs21Az3PLpuJJGUcobguPnGAHiouVyowgFjB0L3NZK1qgmBM5u
BrDVOwCcFbT+Ao3HESTv+lvPppoxirwiq4DB4B6UAiuAGXvi/0hEDt8mR+XEfCelTnki3e3PPEoha
8npRwKiG38jsldYs=;
Received: from mail-il1-f178.google.com ([209.85.166.178])
by sfi-mx-1.v28.lw.sourceforge.com with esmtps
(TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95)
id 1pQTVm-00HFGC-FY for openvpn-devel@lists.sourceforge.net;
Fri, 10 Feb 2023 13:32:27 +0000
Received: by mail-il1-f178.google.com with SMTP id s9so1011658ilt.1
for <openvpn-devel@lists.sourceforge.net>;
Fri, 10 Feb 2023 05:32:22 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to;
bh=SSuyvT/PSd4Qxdi/yizfF6ZWaGvQcAfWlh9Bs63Ddrg=;
b=hM3oUpCwqkTkrZoh0SJV2IuUJtUQ++lVv9QEn1XbRXFBR4C7EhVoOHotONBiVwvHKX
vrExU+QBCdqUWLUsSIDztZopyqCcgNUtw+zGGaVrFx/bz61lFN+0wsHLWbRlpXh4oxc5
QsF0kR83VbQHVCyvuMofvEu7HYnKw139PdrDb0M+672vrS81EfLmA/NTzsvrfIAN6krA
p/Zoj9eZQqQUQZWWOiz7nyiCx5reAz9hQ7WyH2zOu9ur0WI88aEQ9Yl8pKl/oa1JLDj5
qigIXsfbZ3kb1k8s1Vp3Itohx25h6uslohT6HHWsrxJnG9zAiFOfYU7O+ufqkTwDqcgy
BoWg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=SSuyvT/PSd4Qxdi/yizfF6ZWaGvQcAfWlh9Bs63Ddrg=;
b=NdmsUWG05Wnj+kxa/Nduyzp4n1HEpsuQgn7dnv61eKOM7pcSPB0MCCFQrzl404HwSw
WYS8Plyk/0TUaDgaE0HIeyjHNf4RdKcA9UeC2ye12TqC/50wpGZbJUOY5gnmSCfBLy9P
9dz2TAH3JTSrrWNAZRhw/eTeLxTJfUl9PWnwuKk8mWz6fsWN3cx6Z/SwZD2KuRk/EL+1
PMzDPAysPqWDtSjgS5ZGey2SvOY2CN9JEsCSP+u3K0dyBFkr0LMHMrP246ThDwe13+jA
gVGsIW2YqpdPB+NY7ipBFlfkPSt7TbYwx7WbBXzNiBVitlr/BZnpeZOiLbgDFKrsETns
ty2Q==
X-Gm-Message-State: AO0yUKWc3+EO90FKDtyNToRjRgE+TASYkn+1CgofH6Eq35RbWZIo09L+
QTRBK7KlX9hXuggcXc5Atp6uCF409YE4ySwg
X-Received: by 2002:a05:6e02:2168:b0:313:eee4:1365 with SMTP id
s8-20020a056e02216800b00313eee41365mr9756838ilv.4.1676035936554;
Fri, 10 Feb 2023 05:32:16 -0800 (PST)
Received: from localhost.localdomain (nat1.panoulu.net. [185.38.2.1])
by smtp.gmail.com with ESMTPSA id
q4-20020a0566380ec400b003b77432cc37sm1397036jas.106.2023.02.10.05.32.15
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Fri, 10 Feb 2023 05:32:16 -0800 (PST)
From: Lev Stipakov <lstipakov@gmail.com>
To: openvpn-devel@lists.sourceforge.net
Date: Fri, 10 Feb 2023 15:31:59 +0200
Message-Id: <20230210133159.1336-1-lstipakov@gmail.com>
X-Mailer: git-send-email 2.23.0.windows.1
MIME-Version: 1.0
X-Spam-Score: -0.2 (/)
X-Spam-Report: Spam detection software,
running on the system "util-spamd-2.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: From: Lev Stipakov Socket is a handle on Windows, which is
usually logged in hex. Also an interesting value is INVALID_SOCKET, which
is ~0. PRIuPTR prints decimals, and for INVALID_SOCKET it prints something
like Content analysis details: (-0.2 points, 6.0 required)
pts rule name description
---- ----------------------
--------------------------------------------------
-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/,
no trust [209.85.166.178 listed in list.dnswl.org]
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
provider [lstipakov[at]gmail.com]
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_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.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2)
[209.85.166.178 listed in wl.mailspike.net]
X-Headers-End: 1pQTVm-00HFGC-FY
Subject: [Openvpn-devel] [PATCH] Improve format specifier for socket handle
in Windows
X-BeenThere: openvpn-devel@lists.sourceforge.net
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <openvpn-devel.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>,
<mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive:
<http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel>
List-Post: <mailto:openvpn-devel@lists.sourceforge.net>
List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>,
<mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe>
Cc: Lev Stipakov <lev@openvpn.net>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: openvpn-devel-bounces@lists.sourceforge.net
X-getmail-retrieved-from-mailbox: Inbox
X-GMAIL-THRID: =?utf-8?q?1757451125439468357?=
X-GMAIL-MSGID: =?utf-8?q?1757451125439468357?=
|
| Series |
[Openvpn-devel] Improve format specifier for socket handle in Windows
|
|
Commit Message
Lev Stipakov
Feb. 10, 2023, 1:31 p.m. UTC
From: Lev Stipakov <lev@openvpn.net> Socket is a handle on Windows, which is usually logged in hex. Also an interesting value is INVALID_SOCKET, which is ~0. PRIuPTR prints decimals, and for INVALID_SOCKET it prints something like 2023-02-10 14:45:21 us=906000 write to TUN/TAP : Jrjestelmkutsulle annettu data-alue on liian pieni. (fd=18446744073709551615,code=122) PRIxPTR prints hex, and INVALID_SOCKET looks a bit nicer: 2023-02-10 15:17:11 us=828000 write to TUN/TAP : Jrjestelmkutsulle annettu data-alue on liian pieni. (fd=ffffffffffffffff,code=122) Reported-by: Selva Nair <selva.nair@gmail.com> Signed-off-by: Lev Stipakov <lev@openvpn.net> --- src/openvpn/syshead.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Feb 10, 2023 at 03:31:59PM +0200, Lev Stipakov wrote: > From: Lev Stipakov <lev@openvpn.net> > > Socket is a handle on Windows, which is usually logged in hex. > Also an interesting value is INVALID_SOCKET, which is ~0. > > PRIuPTR prints decimals, and for INVALID_SOCKET it prints something like > > 2023-02-10 14:45:21 us=906000 write to TUN/TAP : Jrjestelmkutsulle > annettu data-alue on liian pieni. (fd=18446744073709551615,code=122) > > PRIxPTR prints hex, and INVALID_SOCKET looks a bit nicer: > > 2023-02-10 15:17:11 us=828000 write to TUN/TAP : Jrjestelmkutsulle > annettu data-alue on liian pieni. (fd=ffffffffffffffff,code=122) > Acked-By: Frank Lichtenheld <frank@lichtenheld.com> Regards,
Hi, On 10/02/2023 14:31, Lev Stipakov wrote: > From: Lev Stipakov <lev@openvpn.net> > > Socket is a handle on Windows, which is usually logged in hex. > Also an interesting value is INVALID_SOCKET, which is ~0. > > PRIuPTR prints decimals, and for INVALID_SOCKET it prints something like > > 2023-02-10 14:45:21 us=906000 write to TUN/TAP : Jrjestelmkutsulle > annettu data-alue on liian pieni. (fd=18446744073709551615,code=122) > > PRIxPTR prints hex, and INVALID_SOCKET looks a bit nicer: > > 2023-02-10 15:17:11 us=828000 write to TUN/TAP : Jrjestelmkutsulle > annettu data-alue on liian pieni. (fd=ffffffffffffffff,code=122) > > Reported-by: Selva Nair <selva.nair@gmail.com> > Signed-off-by: Lev Stipakov <lev@openvpn.net> I also discussed this with Lev and, despite this being different from what we do in the *nix world (where decimal representations make sense for file descriptors), it seems to be the right hting to do on Windows when using HANDLEs (shrug). Acked-by: Antonio Quartulli <a@unstable.cc>
Hi On Fri, Feb 10, 2023 at 2:21 PM Antonio Quartulli <a@unstable.cc> wrote: > Hi, > > On 10/02/2023 14:31, Lev Stipakov wrote: > > From: Lev Stipakov <lev@openvpn.net> > > > > Socket is a handle on Windows, which is usually logged in hex. > > Also an interesting value is INVALID_SOCKET, which is ~0. > > > > PRIuPTR prints decimals, and for INVALID_SOCKET it prints something like > > > > 2023-02-10 14:45:21 us=906000 write to TUN/TAP : Jrjestelmkutsulle > > annettu data-alue on liian pieni. (fd=18446744073709551615,code=122) > > > > PRIxPTR prints hex, and INVALID_SOCKET looks a bit nicer: > > > > 2023-02-10 15:17:11 us=828000 write to TUN/TAP : Jrjestelmkutsulle > > annettu data-alue on liian pieni. (fd=ffffffffffffffff,code=122) > > > > Reported-by: Selva Nair <selva.nair@gmail.com> > > Signed-off-by: Lev Stipakov <lev@openvpn.net> > > I also discussed this with Lev and, despite this being different from > what we do in the *nix world (where decimal representations make sense > for file descriptors), it seems to be the right hting to do on Windows > when using HANDLEs (shrug). > Windows kernel handles are very much "like" fds though the handle table also covers processes, threads, semaphores etc. They are not pointers, are generally smallish numbers or ~0 (== -1). But not as small as fds in the Unix/Linux world --- mainly because several objects share the name space and they have to be multiples of 4 for some arcane reason. The problem here was not printing as "decimal" but as "unsigned decimal". Use of the latter would have caused the same issue on Linux too. Using hex is a compromise here as handles are defined as "unsigned ints" of the same size as pointers. So PRIdPTR somehow looks improper though I would have chosen that. Selva
Hi, On 10/02/2023 20:54, Selva Nair wrote: > > I also discussed this with Lev and, despite this being different from > what we do in the *nix world (where decimal representations make sense > for file descriptors), it seems to be the right hting to do on Windows > when using HANDLEs (shrug). > > > Windows kernel handles are very much "like" fds though the handle table > also covers processes, threads, semaphores etc. They are not pointers, > are generally smallish numbers or ~0 (== -1). But not as small as fds in > the Unix/Linux world --- mainly because several objects share the name > space and they have to be multiples of 4 for some arcane reason. > > The problem here was not printing as "decimal" but as "unsigned > decimal". Use of the latter would have caused the same issue on Linux too. > > Using hex is a compromise here as handles are defined as "unsigned ints" > of the same size as pointers. So PRIdPTR somehow looks improper though I > would have chosen that. Given your explanation then it sounds like we should truly use PRIdPTR. Wouldn't you agree Lev? Cheers, > > Selva > > > _______________________________________________ > Openvpn-devel mailing list > Openvpn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Am 10.02.23 um 23:07 schrieb Antonio Quartulli: > Hi, > > On 10/02/2023 20:54, Selva Nair wrote: >> >> I also discussed this with Lev and, despite this being different from >> what we do in the *nix world (where decimal representations make >> sense >> for file descriptors), it seems to be the right hting to do on >> Windows >> when using HANDLEs (shrug). >> >> >> Windows kernel handles are very much "like" fds though the handle >> table also covers processes, threads, semaphores etc. They are not >> pointers, are generally smallish numbers or ~0 (== -1). But not as >> small as fds in the Unix/Linux world --- mainly because several >> objects share the name space and they have to be multiples of 4 for >> some arcane reason. >> >> The problem here was not printing as "decimal" but as "unsigned >> decimal". Use of the latter would have caused the same issue on Linux >> too. >> >> Using hex is a compromise here as handles are defined as "unsigned >> ints" of the same size as pointers. So PRIdPTR somehow looks improper >> though I would have chosen that. > > Given your explanation then it sounds like we should truly use PRIdPTR. > Wouldn't you agree Lev? Not really. The type is still an unsigned type and while -1 is used to denote an invalid HANDLE, the type itself is unsigned, so using a signed printf format specifier like PRIdPTR will probably give us a warning about using about signed vs unsigned. Arne
I'm so not testing this... but I do not need to, the change is trivial
(ok, I cheated, I did test-compile on MinGW).
Your patch has been applied to the master branch.
commit 6731314a82d1a3c76b5497749985ee20c0c7d8eb (master)
commit 8e3331a901dbececc8622e97ed0592ddadf56996 (release/2.6)
Author: Lev Stipakov
Date: Fri Feb 10 15:31:59 2023 +0200
Improve format specifier for socket handle in Windows
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20230210133159.1336-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26220.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index 12ccf2f4..53359225 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -441,7 +441,7 @@ typedef unsigned short sa_family_t; */ #ifdef _WIN32 #define SOCKET_UNDEFINED (INVALID_SOCKET) -#define SOCKET_PRINTF "%" PRIuPTR +#define SOCKET_PRINTF "%" PRIxPTR typedef SOCKET socket_descriptor_t; #else #define SOCKET_UNDEFINED (-1)