]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Use proper print format/casting when converting msg_channel handle
authorArne Schwabe <arne@rfc2549.org>
Tue, 14 Feb 2023 13:43:23 +0000 (14:43 +0100)
committerGert Doering <gert@greenie.muc.de>
Wed, 1 Mar 2023 13:25:18 +0000 (14:25 +0100)
The current casting triggers a warning on 32bit:

    init.c:1842:66: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]

Use the proper printf format specifier for printing a pointer avoiding
the cast alltogether.

In options.c use a cast to intptr_t before converting to a handle to
avoid having to ifdef atoll/atol for 32/64 bit.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230214134323.1033590-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26255.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/init.c
src/openvpn/options.c

index 622239f6b10e2fe8e77c9708f1a6a06d6956b2da..32211f11e531d71206a51021e153778ceb4b3118 100644 (file)
@@ -1850,7 +1850,8 @@ do_open_tun(struct context *c, int *error_flags)
 #ifdef _WIN32
         /* store (hide) interactive service handle in tuntap_options */
         c->c1.tuntap->options.msg_channel = c->options.msg_channel;
-        msg(D_ROUTE, "interactive service msg_channel=%" PRIu64, (unsigned long long) c->options.msg_channel);
+        msg(D_ROUTE, "interactive service msg_channel=%" PRIuPTR,
+            (intptr_t) c->options.msg_channel);
 #endif
 
         /* allocate route list structure */
index 9105449c7f8c0238849e41a651b3d3c3c87fc346..2e41eea4e2c41abb2080d0971ea142d535b2f7df 100644 (file)
@@ -7876,7 +7876,7 @@ add_option(struct options *options,
 #ifdef _WIN32
         VERIFY_PERMISSION(OPT_P_GENERAL);
         HANDLE process = GetCurrentProcess();
-        HANDLE handle = (HANDLE) atoll(p[1]);
+        HANDLE handle = (HANDLE) ((intptr_t) atoll(p[1]));
         if (!DuplicateHandle(process, handle, process, &options->msg_channel, 0,
                              FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS))
         {