Re: [PATCH] Fix infinite loop in gpgme data_object_to_stream().

Alejandro Colomar via Mutt-dev <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <aeR5xZujerHIPZlk@devuan>
Hi Kevin,

On 2026-04-19T13:49:31+0800, Kevin J. McCarthy wrote:
> The code was not properly checking for a -1 return value in the read,
> leading to an infinite loop, and printing past the buffer value to the
> stream.
> 
> Thanks to [email protected] for the security report.
> ---
> This is 2 in the list evilrabbit sent.
> 
> Thanks for the suggestion Alex, but it reads a little funny compared to
> the rest of the codebase, so I'm keeping the comparision as is for this
> fix. :-D

That's fine.  :-)

Reviewed-by: Alejandro Colomar <[email protected]>


Cheers,
Alex

> 
>  crypt-gpgme.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/crypt-gpgme.c b/crypt-gpgme.c
> index 5313d6f2..4e0bcf2f 100644
> --- a/crypt-gpgme.c
> +++ b/crypt-gpgme.c
> @@ -742,7 +742,7 @@ static int data_object_to_stream (gpgme_data_t data, FILE *fp)
>        return -1;
>      }
>  
> -  while ((nread = gpgme_data_read (data, buf, sizeof (buf))))
> +  while ((nread = gpgme_data_read(data, buf, sizeof (buf))) > 0)
>      {
>        /* fixme: we are not really converting CRLF to LF but just
>           skipping CR. Doing it correctly needs a more complex logic */
> -- 
> 2.53.0
> 

-- 
<https://www.alejandro-colomar.es>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmnkeeMACgkQ64mZXMKQ
wqlHkRAAgmBeqBE6kVxM7WEoH3RRXUvRiL1j1YOiVHyc8ApClErwLfeaxE0RfdyF
7Rn9aEkNxjLsb6ydg/V6lxCK4Tj6/xnIO/MAfOPhZ433JIZaGZjq+KcY6kiju8SH
wlQfPbVOqzaHnkNQ3Y4wrlzYtreYYV2zyrqFHiH5AxvlZtdyEoUmFnTP+n6mEwI8
GzwY37sSviiwX0WqGxRU+IGB0CwdZRKnmGKJcLUUSXmbG+218wv3p7fBG/rNuVWj
USp2X+pYkvNLbuq573CMoKR6tgawR001kICwrt5Odz2CfBSBwGHEuYSZwVs6B4FA
t4Kqa9uZBmibJzDPtgurTjcvTe14i8URjh13TQwVcleHv+KplVSU3oXPBymGx1w5
7MPK7WNiDXt0Hvgs6Og2IZuJs66ajB0Rp1eAT6Mgp6mK00iNNM4C8xihtHObiNMZ
d3tnE6QvcwyTTbcYfRaZJMpOg3124XwFDqpbFIJM9gO5gqxb3KG+qf0HQ9j5oLdy
fSOrXYw1sRHDnSEJ2PEKy8eieRTEKrz6LvWRij3ZmUliNLcVPyYZTPxTac0Rsubm
2kTFcZ8oh0P3dezIiGlwRSzv5/yvM1CwTY9ryoecy13i+y1JfwwjJ/D30AVWNEif
gmR0RBOrAmVETtabl+ReXvlkSEaGFXdTxZhKYkzv+XQZjV+9qQ4=
=6G1Z
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.