Re: [PATCH] Search for keys by uid using utf-8.
"Kevin J. McCarthy" <[email protected]> Mon, 18 May 2026 20:45:10 +0800
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <agsJ1s1wM075Xbht@qinghai> |
On Mon, May 18, 2026 at 01:03:29PM +0200, Alejandro Colomar via Mutt-dev wrote:
>> + mailbox = safe_malloc(mutt_strlen(utf8_user) + mutt_strlen(utf8_domain) + 2);
>> + sprintf(mailbox, "%s@%s", NONULL(utf8_user), NONULL(utf8_domain)); /* __SPRINTF_CHECKED__ */
>
>Should we use an sprintf(3) variant that allocates itself? That could
>simplify this to:
>
> mailbox = aprintf("%s@%s", NONULL(utf8_user), NONULL(utf8_domain));
> if (mailbox == NULL)
> goto fail;
Hi Alex,
Actually sprintf() usage in mutt is pretty rare. The check_sec.sh
script scans for it and requires an explicit comment for it to be
allowed.
The only reason I used it in this case is because it's used in the other
two conversion functions in mutt_idna.c, and as I mentioned, I modelled
this one off of those for consistency and ease of understanding.
There is a safe_asprintf() equivalent in the mutt codebase in
safe_asprintf.c, but surprisingly it's only used in four places in the
code!
I could change it here, but then I should probably change it in the
other two functions to match. If you'd like I can make a separate patch
to change it in all three places.
--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmoLCdYACgkQre92hIAx a9oByw//Ym0ApiJr0pSHsB1w4VMgZ6yPY+hLSM/R2Ey+NMZyknQ4iRdzvYHnrPkt jfx+te5fwoiFLqdo3+nWRmFO8WbGz2eamqYB+E7eg3EjsczGUpls+nOsgLx0I43z DomvnhyUinHUus/JhsfqlR6v/9LPZyIGJIXUUHg6g2uniQ1bCFYJ4ghUABXAScqe eD0+0BAoMy9C/5DFEO5oTNBt08IhVXPvgL8wbuFUs+I0JwUgBvJA+GjzBvOjOOH3 8+whgfu7MOpVHw3hfQ54oZ2NxtmjhHBCqLwnKapgIup9hfoUg53l3AMWGOpVn90g Zs4jnYqLndWThANAKXqxDFaMEvFSRwzHRP1WwKtCqaO3P0A/enf0NaOOJyoQnbqU 4OmWCNOfTEB1ZjE36t3pBrNowmFAiTZNaavEBkLCPZA9GoSKv74+EjfNXQh14BUx 1cFw8uHZBSyTzbvUEMiiPd6Br828VTjFgXyHZH4M6MRkiz2qa4nVhi1S3t+KTGir fAQLlQkW1xIRRrXPNCkybM84GRlBBRN91RVEefqJT2j3FCCA5axPdV9bg0SyzrBv S+OMMZC63UneAFWJkLBypIE14q/3fJ4Gfjp6uR7SA6eYKmxSmJMmWZojxDN7Ikeu 4GLrso0BErzjHlZLs3LALvvnxWIeSyUnusTvdhzqm44ro1iVBik= =mC+s -----END PGP SIGNATURE-----