Gert Doering has submitted this change. ( https://gerrit.openvpn.net/c/openvpn/+/2232?usp=email )
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 Signed-off-by: Razvan Cojocaru <[email protected]> Acked-by: Frank Lichtenheld <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2232 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg41820.html Signed-off-by: Gert Doering <[email protected]> --- M src/openvpn/manage.c 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index d63d53b..addd6f2 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -3881,45 +3881,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) { @@ -3958,7 +3930,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; } @@ -3971,10 +3943,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: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I49bc1fe0b2c2a71f2f37491a1b44d4cacc8a706b Gerrit-Change-Number: 2232 Gerrit-PatchSet: 3 Gerrit-Owner: Răzvan Cojocaru <[email protected]> Gerrit-Reviewer: Arne Schwabe <[email protected]> Gerrit-Reviewer: Frank Lichtenheld <[email protected]> Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
