From 644b4abc6c17d470e91f876601ef603fab293b81 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 5 Jun 2003 23:39:28 +0000 Subject: [PATCH] 2003-06-06 Marcus Brinkmann * rungpg.c (struct engine_gpg): Remove arg_error. (add_arg): Don't set arg_error. (add_data): Likewise. (start): Don't check arg_error. (gpg_new): Check return value of add_arg. * verify.c (parse_notation): Free allocated memory at error. --- trunk/TODO | 2 -- trunk/gpgme/ChangeLog | 9 ++++++++ trunk/gpgme/rungpg.c | 50 +++++++++++++++++++++++-------------------- trunk/gpgme/verify.c | 12 +++++++++-- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/trunk/TODO b/trunk/TODO index a57665d..fb02739 100644 --- a/trunk/TODO +++ b/trunk/TODO @@ -2,8 +2,6 @@ Hey Emacs, this is -*- outline -*- mode! * Before release: ** Change gpgme_invalid_user_id_t to gpgme_invalid_key_t. -** Remove arg_error from rungpg.c -** Make sure that notation value allocation has no leak at error ** Make sure POSIX I/O functions set errno properly ** gpgme-config must include info about libgpg-error. diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index a3b2d3f..2ba0889 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,12 @@ +2003-06-06 Marcus Brinkmann + + * rungpg.c (struct engine_gpg): Remove arg_error. + (add_arg): Don't set arg_error. + (add_data): Likewise. + (start): Don't check arg_error. + (gpg_new): Check return value of add_arg. + * verify.c (parse_notation): Free allocated memory at error. + 2003-06-05 Marcus Brinkmann Everywhere: Use libgpg-error error codes. diff --git a/trunk/gpgme/rungpg.c b/trunk/gpgme/rungpg.c index 9f992b7..d29a718 100644 --- a/trunk/gpgme/rungpg.c +++ b/trunk/gpgme/rungpg.c @@ -74,7 +74,6 @@ struct engine_gpg { struct arg_and_data_s *arglist; struct arg_and_data_s **argtail; - int arg_error; struct { @@ -191,10 +190,7 @@ add_arg (engine_gpg_t gpg, const char *arg) a = malloc (sizeof *a + strlen (arg)); if (!a) - { - gpg->arg_error = 1; - return gpg_error_from_errno (errno); - } + return gpg_error_from_errno (errno); a->next = NULL; a->data = NULL; a->dup_to = -1; @@ -214,10 +210,7 @@ add_data (engine_gpg_t gpg, gpgme_data_t data, int dup_to, int inbound) a = malloc (sizeof *a - 1); if (!a) - { - gpg->arg_error = 1; - return gpg_error_from_errno (errno); - } + return gpg_error_from_errno (errno); a->next = NULL; a->data = data; a->inbound = inbound; @@ -376,16 +369,25 @@ gpg_new (void **engine) goto leave; } gpg->status.eof = 0; - add_arg (gpg, "--status-fd"); + rc = add_arg (gpg, "--status-fd"); + if (rc) + goto leave; + { char buf[25]; sprintf (buf, "%d", gpg->status.fd[1]); - add_arg (gpg, buf); + rc = add_arg (gpg, buf); + if (rc) + goto leave; } - add_arg (gpg, "--no-tty"); - add_arg (gpg, "--charset"); - add_arg (gpg, "utf8"); - add_arg (gpg, "--enable-progress-filter"); + + rc = add_arg (gpg, "--no-tty"); + if (!rc) + rc = add_arg (gpg, "--charset"); + if (!rc) + rc = add_arg (gpg, "utf8"); + if (!rc) + rc = add_arg (gpg, "--enable-progress-filter"); leave: if (rc) @@ -476,12 +478,19 @@ gpg_set_command_handler (void *engine, engine_command_handler_t fnc, void *fnc_value, gpgme_data_t linked_data) { engine_gpg_t gpg = engine; + gpgme_error_t rc; + + rc = add_arg (gpg, "--command-fd"); + if (rc) + return err; - add_arg (gpg, "--command-fd"); /* This is a hack. We don't have a real data object. The only thing that matters is that we use something unique, so we use the address of the cmd structure in the gpg object. */ - add_data (gpg, (void *) &gpg->cmd, -2, 0); + rc = add_data (gpg, (void *) &gpg->cmd, -2, 0); + if (rc) + return err; + gpg->cmd.fnc = fnc; gpg->cmd.cb_data = (void *) &gpg->cmd; gpg->cmd.fnc_value = fnc_value; @@ -1028,11 +1037,6 @@ start (engine_gpg_t gpg) if (! _gpgme_get_gpg_path ()) return gpg_error (GPG_ERR_INV_ENGINE); - /* Kludge, so that we don't need to check the return code of all the - add_arg (). We bail out here instead. */ - if (gpg->arg_error) - return gpg_error (GPG_ERR_ENOMEM); - rc = build_argv (gpg); if (rc) return rc; @@ -1548,7 +1552,7 @@ gpg_sign (void *engine, gpgme_data_t in, gpgme_data_t out, if (!err && use_armor) err = add_arg (gpg, "--armor"); if (!err && use_textmode) - add_arg (gpg, "--textmode"); + err = add_arg (gpg, "--textmode"); } if (!err) diff --git a/trunk/gpgme/verify.c b/trunk/gpgme/verify.c index a358772..105d1c4 100644 --- a/trunk/gpgme/verify.c +++ b/trunk/gpgme/verify.c @@ -315,7 +315,11 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args) } err = _gpgme_decode_percent_string (args, ¬ation->name, len); if (err) - return err; + { + free (notation->name); + free (notation); + return err; + } notation->value = NULL; } @@ -333,7 +337,11 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args) } err = _gpgme_decode_percent_string (args, ¬ation->value, len); if (err) - return err; + { + free (notation->value); + free (notation); + return err; + } } *lastp = notation; } -- 2.26.2