[PATCH gpgme] Fix an uninitialized variable.
Collin Funk
collin.funk1 at gmail.com
Fri Jul 4 05:42:43 CEST 2025
Collin Funk <collin.funk1 at gmail.com> writes:
> * src/engine-gpg.c (gpg_getdirect): Initialize ERR to zero to satisfy
> the loop condition.
>
> --
>
> Fixes-commit: 0a64c7d0c6d0463cf2e06b3a01ef5be4d879bcf0
> Signed-off-by: Collin Funk <collin.funk1 at gmail.com>
> ---
> src/engine-gpg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/engine-gpg.c b/src/engine-gpg.c
> index b3399027..c6c5c4e6 100644
> --- a/src/engine-gpg.c
> +++ b/src/engine-gpg.c
> @@ -4226,7 +4226,7 @@ gpg_getdirect (void *engine, const char *argv[],
> gpgme_data_t dataout, unsigned int flags)
> {
> engine_gpg_t gpg = engine;
> - gpgme_error_t err;
> + gpgme_error_t err = 0;
> int i;
>
> if (!engine || !argv || !dataout || flags)
Hi Werner, forgot to CC. Looks like this was from that commit a few
months ago. The original code:
gpgme_error_t err;
int i;
if (!engine || !argv || !dataout || flags)
return gpg_error (GPG_ERR_INV_VALUE);
for (i=0; !err && argv[i]; i++)
if ((err = add_arg (gpg, argv[i])))
return err;
Basically, the first iteration will always read an uninitialized
variable. Seems mostly harmless and will probably mostly work, but UB is
UB. :)
Collin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20250703/5bfc6796/attachment.sig>
More information about the Gnupg-devel
mailing list