diff options
author | Florian Dold <florian@dold.me> | 2024-10-24 16:00:08 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-10-24 16:00:12 +0200 |
commit | 0ea6f1ee4df9b9868fa32b3b25174dc63a385892 (patch) | |
tree | 4cd998d7687521d557238cd0ffcb2c996126e2ee | |
parent | 758fdf14cb081404adc3cf4bf5bb61730dbffefe (diff) |
do not use varargs for external conversion
The GNUNET_OS_start_process_va is anyway just a wrapper that has to do
extra malloc'ing, whereas GNUNET_OS_start_process_vap doesn't.
This change is also in preparation for command splitting, as varargs
don't allow programmatically constructing a variable size argument list.
-rw-r--r-- | src/include/taler_json_lib.h | 4 | ||||
-rw-r--r-- | src/json/conversion.c | 18 | ||||
-rw-r--r-- | src/kyclogic/kyclogic_api.c | 11 | ||||
-rw-r--r-- | src/kyclogic/plugin_kyclogic_kycaid.c | 26 | ||||
-rw-r--r-- | src/kyclogic/plugin_kyclogic_oauth2.c | 7 | ||||
-rw-r--r-- | src/kyclogic/plugin_kyclogic_persona.c | 13 |
6 files changed, 45 insertions, 34 deletions
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 5e78ab44d..0e8c8fc2b 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -929,7 +929,7 @@ typedef void * @param cb function to call on the result * @param cb_cls closure for @a cb * @param binary name of the binary to execute - * @param ... NULL-terminated list of arguments for the @a binary, + * @param argv NULL-terminated list of arguments for the @a binary, * usually starting with again the name of the binary * @return handle to cancel the operation (and kill the helper) */ @@ -939,7 +939,7 @@ TALER_JSON_external_conversion_start ( TALER_JSON_JsonCallback cb, void *cb_cls, const char *binary, - ...); + const char **argv); /** * Abort external conversion, killing the process and preventing diff --git a/src/json/conversion.c b/src/json/conversion.c index 68568e966..b319eae0b 100644 --- a/src/json/conversion.c +++ b/src/json/conversion.c @@ -298,12 +298,11 @@ TALER_JSON_external_conversion_start (const json_t *input, TALER_JSON_JsonCallback cb, void *cb_cls, const char *binary, - ...) + const char **argv) { struct TALER_JSON_ExternalConversion *ec; struct GNUNET_DISK_PipeHandle *pipe_stdin; struct GNUNET_DISK_PipeHandle *pipe_stdout; - va_list ap; ec = GNUNET_new (struct TALER_JSON_ExternalConversion); ec->cb = cb; @@ -312,15 +311,12 @@ TALER_JSON_external_conversion_start (const json_t *input, GNUNET_assert (NULL != pipe_stdin); pipe_stdout = GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_WRITE); GNUNET_assert (NULL != pipe_stdout); - va_start (ap, - binary); - ec->helper = GNUNET_OS_start_process_va (GNUNET_OS_INHERIT_STD_ERR, - pipe_stdin, - pipe_stdout, - NULL, - binary, - ap); - va_end (ap); + ec->helper = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, + pipe_stdin, + pipe_stdout, + NULL, + binary, + (char *const *) argv); if (NULL == ec->helper) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c index b3dc21df1..366c6fdb0 100644 --- a/src/kyclogic/kyclogic_api.c +++ b/src/kyclogic/kyclogic_api.c @@ -3750,6 +3750,12 @@ TALER_KYCLOGIC_run_aml_program2 ( { json_t *input; + const char *args[] = { + prog->command, + "-c", + cfg_filename, + NULL, + }; input = GNUNET_JSON_PACK ( GNUNET_JSON_pack_allow_null ( @@ -3773,10 +3779,7 @@ TALER_KYCLOGIC_run_aml_program2 ( &handle_aml_output, aprh, prog->command, - prog->command, - "-c", - cfg_filename, - NULL); + args); json_decref (input); } return aprh; diff --git a/src/kyclogic/plugin_kyclogic_kycaid.c b/src/kyclogic/plugin_kyclogic_kycaid.c index a22696a4a..fcf94984b 100644 --- a/src/kyclogic/plugin_kyclogic_kycaid.c +++ b/src/kyclogic/plugin_kyclogic_kycaid.c @@ -967,16 +967,22 @@ handle_webhook_finished (void *cls, resp); break; } - wh->econ - = TALER_JSON_external_conversion_start ( - j, - &webhook_conversion_cb, - wh, - wh->pd->conversion_helper, - wh->pd->conversion_helper, - "-a", - wh->pd->auth_token, - NULL); + { + const char *argv[] = { + wh->pd->conversion_helper, + "-a", + wh->pd->auth_token, + NULL, + }; + + wh->econ + = TALER_JSON_external_conversion_start ( + j, + &webhook_conversion_cb, + wh, + wh->pd->conversion_helper, + argv); + } if (NULL == wh->econ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/kyclogic/plugin_kyclogic_oauth2.c b/src/kyclogic/plugin_kyclogic_oauth2.c index e5d7a0a72..a94e8790b 100644 --- a/src/kyclogic/plugin_kyclogic_oauth2.c +++ b/src/kyclogic/plugin_kyclogic_oauth2.c @@ -1084,6 +1084,10 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph, const json_t *j) { const struct TALER_KYCLOGIC_ProviderDetails *pd = ph->pd; + const char *argv[] = { + pd->conversion_binary, + NULL, + }; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calling converter `%s' with JSON\n", @@ -1096,8 +1100,7 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph, &converted_proof_cb, ph, pd->conversion_binary, - pd->conversion_binary, - NULL); + argv); if (NULL != ph->ec) return; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/kyclogic/plugin_kyclogic_persona.c b/src/kyclogic/plugin_kyclogic_persona.c index 67bd546dd..6b957756e 100644 --- a/src/kyclogic/plugin_kyclogic_persona.c +++ b/src/kyclogic/plugin_kyclogic_persona.c @@ -1022,6 +1022,13 @@ start_conversion (const struct TALER_KYCLOGIC_ProviderDetails *pd, TALER_JSON_JsonCallback cb, void *cb_cls) { + const char *argv[] = { + pd->conversion_binary, + "-a", + pd->auth_token, + NULL, + }; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calling converter `%s' with JSON\n", pd->conversion_binary); @@ -1033,11 +1040,7 @@ start_conversion (const struct TALER_KYCLOGIC_ProviderDetails *pd, cb, cb_cls, pd->conversion_binary, - pd->conversion_binary, - "-a", - pd->auth_token, - NULL - ); + argv); } |