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/+/2095?usp=email
to review the following change.
Change subject: init: simplify management_callback_send_cc_message()
......................................................................
init: simplify management_callback_send_cc_message()
buf_printf() already fails when the output does not fit, so size the
buffer to PUSH_BUNDLE_SIZE and drop the separate length calculation
and its second parameters check. The size limit is unchanged.
Change-Id: Iecdf8c79b2a3aabf26476c7a36c4b132fcef9e45
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M src/openvpn/init.c
1 file changed, 5 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/2095/1
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 6c87865..035f7b6 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -299,24 +299,14 @@
management_callback_send_cc_message(void *arg, const char *command, const char
*parameters)
{
struct context *c = (struct context *)arg;
- size_t len = strlen(command) + 1;
- if (parameters)
- {
- len += 1 + strlen(parameters);
- }
- if (len > PUSH_BUNDLE_SIZE)
- {
- return false;
- }
-
struct gc_arena gc = gc_new();
- struct buffer buf = alloc_buf_gc(len, &gc);
- ASSERT(buf_printf(&buf, "%s", command));
- if (parameters)
+ struct buffer buf = alloc_buf_gc(PUSH_BUNDLE_SIZE, &gc);
+ bool status = false;
+
+ if (buf_printf(&buf, "%s", command) && (!parameters || buf_printf(&buf,
",%s", parameters)))
{
- ASSERT(buf_printf(&buf, ",%s", parameters));
+ status = send_control_channel_string(c, BSTR(&buf), D_PUSH);
}
- bool status = send_control_channel_string(c, BSTR(&buf), D_PUSH);
gc_free(&gc);
return status;
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2095?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: Iecdf8c79b2a3aabf26476c7a36c4b132fcef9e45
Gerrit-Change-Number: 2095
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[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