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/+/2232?usp=email
to review the following change.
Change subject: manage: merge the two multiline flatten helpers
......................................................................
manage: merge the two multiline flatten helpers
management_query_multiline_flatten_newline() differed only in the
aggregate length and separator; pass those as parameters instead.
Change-Id: I49bc1fe0b2c2a71f2f37491a1b44d4cacc8a706b
---
M src/openvpn/manage.c
1 file changed, 7 insertions(+), 36 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/32/2232/1
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 86c498e..3505d6b 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -3905,45 +3905,17 @@
}
static char *
-/* returns allocated base64 signature */
-management_query_multiline_flatten_newline(struct management *man, const char
*b64_data,
- const char *prompt, const char
*cmd, int *state,
- struct buffer_list **input)
-{
- int ok;
- char *result = NULL;
-
- ok = management_query_multiline(man, b64_data, prompt, cmd, state);
- if (ok && buffer_list_defined(*input))
- {
- buffer_list_aggregate_separator(*input, 10000, "\n");
- const struct buffer *buf = buffer_list_peek(*input);
- if (buf && BLEN(buf) > 0)
- {
- result = (char *)malloc(BLENZ(buf) + 1);
- check_malloc_return(result);
- memcpy(result, buf->data, BLENZ(buf));
- result[BLEN(buf)] = '\0';
- }
- }
-
- buffer_list_free(*input);
- *input = NULL;
-
- return result;
-}
-
-static char *
-/* returns allocated base64 signature */
+/* returns allocated, flattened multiline input */
management_query_multiline_flatten(struct management *man, const char
*b64_data, const char *prompt,
- const char *cmd, int *state, struct
buffer_list **input)
+ const char *cmd, int *state, struct
buffer_list **input,
+ const size_t max_len, const char *sep)
{
char *result = NULL;
const int ok = management_query_multiline(man, b64_data, prompt, cmd,
state);
if (ok && buffer_list_defined(*input))
{
- buffer_list_aggregate(*input, 2048);
+ buffer_list_aggregate_separator(*input, max_len, sep);
const struct buffer *buf = buffer_list_peek(*input);
if (buf && BLEN(buf) > 0)
{
@@ -3982,7 +3954,7 @@
}
char *ret = management_query_multiline_flatten(man, (char
*)buf_bptr(&buf_data), prompt, desc,
&man->connection.ext_key_state,
-
&man->connection.ext_key_input);
+
&man->connection.ext_key_input, 2048, "");
free_buf(&buf_data);
return ret;
}
@@ -3995,10 +3967,9 @@
buf_write(&buf_prompt, prompt_1, strlen(prompt_1));
buf_write(&buf_prompt, cert_name, strlen(cert_name) + 1); /* +1 for \0 */
- char *result;
- result = management_query_multiline_flatten_newline(
+ char *result = management_query_multiline_flatten(
man, NULL, (char *)buf_bptr(&buf_prompt), "certificate",
&man->connection.ext_cert_state,
- &man->connection.ext_cert_input);
+ &man->connection.ext_cert_input, 10000, "\n");
free_buf(&buf_prompt);
return result;
}
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2232?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: I49bc1fe0b2c2a71f2f37491a1b44d4cacc8a706b
Gerrit-Change-Number: 2232
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