From: Frank Lichtenheld <[email protected]>

- Use BLENZ instead of buf_len where applicable
- Fix some comparisons with ce list length

Change-Id: Ie0b94b596637d660392bc4eda48d16cfecfeb971
Signed-off-by: Frank Lichtenheld <[email protected]>
Acked-by: Razvan Cojocaru <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1562
---

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/+/1562
This mail reflects revision 8 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <[email protected]>

        
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index caaa769..2196364 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -325,11 +325,6 @@
     return l->len;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
 static bool
 management_callback_remote_entry_get(void *arg, unsigned int index, char 
**remote)
 {
@@ -340,7 +335,7 @@
     struct connection_list *l = c->options.connection_list;
     bool ret = true;
 
-    if (index < l->len)
+    if (l->len > 0 && index < (unsigned int)l->len)
     {
         struct connection_entry *ce = l->array[index];
         const char *proto = proto2ascii(ce->proto, ce->af, false);
@@ -364,10 +359,6 @@
     return ret;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static bool
 management_callback_remote_cmd(void *arg, const char **p)
 {
@@ -466,7 +457,6 @@
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wconversion"
-#pragma GCC diagnostic ignored "-Wsign-compare"
 #endif
 
 /*
@@ -638,8 +628,8 @@
     } while (!ce_defined);
 
     /* Check if this connection attempt would bring us over the limit */
-    if (c->options.connect_retry_max > 0
-        && c->options.unsuccessful_attempts > (l->len * 
c->options.connect_retry_max))
+    int max_attempts = l->len * c->options.connect_retry_max;
+    if (max_attempts > 0 && c->options.unsuccessful_attempts > (unsigned 
int)max_attempts)
     {
         msg(M_FATAL, "All connections have been connect-retry-max (%d) times 
unsuccessful, exiting",
             c->options.connect_retry_max);
@@ -2176,7 +2166,7 @@
 static void
 add_delim_if_non_empty(struct buffer *buf, const char *header)
 {
-    if (buf_len(buf) > strlen(header))
+    if (BLENZ(buf) > strlen(header))
     {
         buf_printf(buf, ", ");
     }
@@ -2264,7 +2254,7 @@
         buf_printf(&out, "session-timeout %d", o->session_timeout);
     }
 
-    if (buf_len(&out) > strlen(header))
+    if (BLENZ(&out) > strlen(header))
     {
         msg(D_HANDSHAKE, "%s", BSTR(&out));
     }
@@ -2301,7 +2291,7 @@
         }
     }
 
-    if (buf_len(&out) > strlen(header))
+    if (BLENZ(&out) > strlen(header))
     {
         msg(D_HANDSHAKE, "%s", BSTR(&out));
     }


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to