[Openvpn-devel,v1] push: Avoid conversion warnings in send_push_options
Commit Message
From: Frank Lichtenheld <frank@lichtenheld.com>
Make sure we have a sane length and convert it to int.
Change-Id: I6b03ba939387c2a873105f6b6cd5f18efbf4dd4c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2005
---
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/+/2005
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
Gert Doering <gert@greenie.muc.de>
@@ -733,11 +733,6 @@
}
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
static bool
send_push_options(struct context *c, struct buffer *buf, struct push_list *push_list, int safe_cap,
bool *push_sent, bool *multi_push)
@@ -748,8 +743,13 @@
{
if (e->enable)
{
- const int l = strlen(e->option);
- if (BLEN(buf) + l >= safe_cap)
+ const size_t l = strlen(e->option);
+ if (!buf_size_valid(l))
+ {
+ msg(M_WARN, "--push option is too long");
+ return false;
+ }
+ if (BLEN(buf) + (int)l >= safe_cap)
{
buf_printf(buf, ",push-continuation 2");
{
@@ -764,7 +764,7 @@
buf_printf(buf, "%s", push_reply_cmd);
}
}
- if (BLEN(buf) + l >= safe_cap)
+ if (BLEN(buf) + (int)l >= safe_cap)
{
msg(M_WARN, "--push option is too long");
return false;
@@ -776,10 +776,6 @@
return true;
}
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
void
send_push_reply_auth_token(struct tls_multi *multi)
{