]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
error: Allow status argument to check_status to be ssize_t master
authorFrank Lichtenheld <frank@lichtenheld.com>
Wed, 26 Nov 2025 11:40:40 +0000 (12:40 +0100)
committerGert Doering <gert@greenie.muc.de>
Wed, 26 Nov 2025 18:31:49 +0000 (19:31 +0100)
We only check for < 0 so no reason not to allow bigger
signed values. This makes it easier to feed result
values of read/write to it. Fixes a conversion warning
in process_outgoing_tun.

Also changes register_activity to int64_t for similar
reasons.

Change-Id: I750a46246c0d2447a6691e5c25c4732e3d335a63
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1357
Message-Id: <20251126114047.10280-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34701.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/error.c
src/openvpn/error.h
src/openvpn/forward.c
src/openvpn/forward.h

index bd588d4cb30704f1ee711689dc5afa7fe3f95c8c..83eb9ebbcf612d4b28d58a5641c06e101754ceb0 100644 (file)
@@ -621,14 +621,14 @@ set_check_status(unsigned int info_level, unsigned int verbose_level)
  * from the OS.
  */
 void
-x_check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
+x_check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
 {
     const char *extended_msg = NULL;
 
     bool crt_error = false;
     int my_errno = openvpn_errno_maybe_crt(&crt_error);
 
-    msg(x_cs_verbose_level, "%s %s returned %d",
+    msg(x_cs_verbose_level, "%s %s returned %zd",
         sock ? proto2ascii(sock->info.proto, sock->info.af, true) : "", description, status);
 
     if (status < 0)
index 2913498f588bedc3af989d67c677d652d68fc3c6..3088dbb615cbddafb12e647f2e74e54672f2e335 100644 (file)
@@ -307,11 +307,11 @@ void reset_check_status(void);
 
 void set_check_status(unsigned int info_level, unsigned int verbose_level);
 
-void x_check_status(int status, const char *description, struct link_socket *sock,
+void x_check_status(ssize_t status, const char *description, struct link_socket *sock,
                     struct tuntap *tt);
 
 static inline void
-check_status(int status, const char *description, struct link_socket *sock, struct tuntap *tt)
+check_status(ssize_t status, const char *description, struct link_socket *sock, struct tuntap *tt)
 {
     if (status < 0 || check_debug_level(x_cs_verbose_level))
     {
index ccb84043803977c1b53b838bb73d6a58e6d31d01..bc600d6cd2f41ab9e596f7e75a4e45bf9be35e7b 100644 (file)
@@ -1673,6 +1673,10 @@ ipv6_send_icmp_unreachable(struct context *c, struct buffer *buf, bool client)
 #undef MAX_ICMPV6LEN
 }
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
 void
 process_ip_header(struct context *c, unsigned int flags, struct buffer *buf,
                   struct link_socket *sock)
@@ -1915,7 +1919,7 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
         /*
          * Write to TUN/TAP device.
          */
-        int size;
+        ssize_t size;
 
 #ifdef LOG_RW
         if (c->c2.log_rw)
@@ -1956,7 +1960,7 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
             if (size != BLEN(&c->c2.to_tun))
             {
                 msg(D_LINK_ERRORS,
-                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%d)",
+                    "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%zd)",
                     c->c1.tuntap->actual_name, BLEN(&c->c2.to_tun), size);
             }
 
@@ -1977,10 +1981,6 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
     buf_reset(&c->c2.to_tun);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 pre_select(struct context *c)
 {
index a575fafe4b74d2f024a6572c6878dd6049bb49f6..3cd710ed0d0086f5c693e673a2831bd3c3cae896 100644 (file)
@@ -343,7 +343,7 @@ get_link_socket_info(struct context *c)
 }
 
 static inline void
-register_activity(struct context *c, const int size)
+register_activity(struct context *c, const int64_t size)
 {
     if (c->options.inactivity_timeout)
     {