Gert Doering has uploaded a new patch set (#2) to the change originally created 
by Frank Lichtenheld. ( https://gerrit.openvpn.net/c/openvpn/+/2004?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by Gert Doering, Code-Review+2 by Răzvan Cojocaru


Change subject: misc: Avoid conversion warnings in parse_auth_challenge
......................................................................

misc: Avoid conversion warnings in parse_auth_challenge

Make sure we have a sane length and convert it int.

Change-Id: I0245175f2884d56838990f53cee6381b981b79c1
Signed-off-by: Frank Lichtenheld <[email protected]>
Acked-by: Razvan Cojocaru <[email protected]>
Acked-by: Gert Doering <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2004
Message-Id: <[email protected]>
URL: 
https://www.mail-archive.com/[email protected]/msg40030.html
Signed-off-by: Gert Doering <[email protected]>
---
M src/openvpn/misc.c
1 file changed, 13 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/2004/2

diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c
index b9cc6a2..304a87e 100644
--- a/src/openvpn/misc.c
+++ b/src/openvpn/misc.c
@@ -72,11 +72,6 @@
 #endif
 }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 #ifdef ENABLE_MANAGEMENT
 /* Get username/password from the management interface */
 static bool
@@ -127,19 +122,23 @@
 parse_auth_challenge(const char *auth_challenge, struct gc_arena *gc)
 {
     ASSERT(auth_challenge);
+    const size_t len = strlen(auth_challenge);
+    if (!buf_size_valid(len))
+    {
+        return NULL;
+    }

-    struct auth_challenge_info *ac;
-    const int len = strlen(auth_challenge);
-    char *work = (char *)gc_malloc(len + 1, false, gc);
-    const char *cp;
+    const int work_len = (int)len + 1;
+    char *work = (char *)gc_malloc(work_len, false, gc);

     struct buffer b;
     buf_set_read(&b, (const uint8_t *)auth_challenge, len);

+    struct auth_challenge_info *ac;
     ALLOC_OBJ_CLEAR_GC(ac, struct auth_challenge_info, gc);

     /* parse prefix */
-    if (!buf_parse(&b, ':', work, len))
+    if (!buf_parse(&b, ':', work, work_len))
     {
         return NULL;
     }
@@ -149,11 +148,11 @@
     }

     /* parse flags */
-    if (!buf_parse(&b, ':', work, len))
+    if (!buf_parse(&b, ':', work, work_len))
     {
         return NULL;
     }
-    for (cp = work; *cp != '\0'; ++cp)
+    for (const char *cp = work; *cp != '\0'; ++cp)
     {
         const char c = *cp;
         if (c == 'E')
@@ -167,14 +166,14 @@
     }

     /* parse state ID */
-    if (!buf_parse(&b, ':', work, len))
+    if (!buf_parse(&b, ':', work, work_len))
     {
         return NULL;
     }
     ac->state_id = string_alloc(work, gc);

     /* parse user name */
-    if (!buf_parse(&b, ':', work, len))
+    if (!buf_parse(&b, ':', work, work_len))
     {
         return NULL;
     }
@@ -189,10 +188,6 @@

 #endif /* ifdef ENABLE_MANAGEMENT */

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /*
  * Get and store a username/password
  */

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2004?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0245175f2884d56838990f53cee6381b981b79c1
Gerrit-Change-Number: 2004
Gerrit-PatchSet: 2
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-Reviewer: Răzvan Cojocaru <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to