Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2004?usp=email
to review the following change.
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]>
---
M src/openvpn/misc.c
1 file changed, 13 insertions(+), 18 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/2004/1
diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c
index 0e4669a..b420aac 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: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0245175f2884d56838990f53cee6381b981b79c1
Gerrit-Change-Number: 2004
Gerrit-PatchSet: 1
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel