Re: Fwd: report 3/3: latent unterminated buffer in imap_wordcasecmp()
"Kevin J. McCarthy" <[email protected]> Fri, 19 Jun 2026 13:37:35 +0800
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jun 19, 2026 at 01:29:21AM -0400, Kurt Hackenberg wrote: >On Fri, Jun 19, 2026 at 13:02 +0800, Kevin J. McCarthy wrote: > >>However, this "utility" function is pretty lousy, and as Ian >>mentions I can't think of any reason to copy b over to a tmp[] >>array. > >Agreed. > >>If we're going to rewrite it, why don't we just compute length of a, >>grab the strcpn() retval as length of b, and if they match then just >>use ascii_strncmp()? > >That ought to work. > >First thing I thought of was to combine everything in a single loop: >caseless compare of a pair of characters, with a terminated by NUL, >and b terminated by either NUL or whitespace. (Also, this function >doesn't have to return strcmp()-style < == or >; can just return >boolean, match or not.) > >Is there some reason not to code a caseless compare of two characters >in this function? Some reason we have to use ascii_strncmp() or >whatever? Ah, sorry, that's right. I meant to propose ascii_strncasecmp() -- 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----- iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmo01Z8ACgkQre92hIAx a9qyyhAAxC+AEsEVC+CweCVqI+LehicvxMNpwawJOXCO13GBgc6xDjrgeJxVGzg2 ZVnH8Egb7LiApRhM/47Z1U6Hax+JvgNn65/plTEFjXQgFsqNjBNGQ6XB7OWqbG32 tieF4E56jAG4cHlRYlmb6C8ZZNRLXUNvjHHP4fa89Jy3wuYm7cg7JAaMXl2za3Hs 9GSD7Fms6WJZlbxKPpXT6UsFN2fVgMkvUKE0nRbpUc7oU7z/hgCNxpWwIkMx3GEH M5hVF/RUfH6cHcMRrBxxeAK8m4K8gVcYxaoO+MImndDtBhNQTdB59J84ixIj4ha0 XfRRUtFyFWbZKrfzoFRketHVdylVsWkueHEiJBJsIadXdU2wEdywKc2Isery4a6e Qfq1+pgtFsacvWkrE0uwuRY4JsOB1bug2N7Ssh17UDDJUN+j1iNIug5tyN8Qw6c6 lFOF6FLN5blMjXTCcD42Oad+SKR+J7I8AKHvHLYYRTilsI+ECWNz+1Fr3wuSMFkI O0o2X+MRYw/KtOEIXR6w5rJgB6vYQ+D+v30pqHNoZnlUvxJZ7xOkoJGdt8xrhjpz nNN1c1ty7LwkMsmbVQ8GyP5JsXBFHjDrWAyT9ogG2ksh2Q3DDpxE4a+JYEXX6LXk K6JImhzd/t/7PgeCov0BlUdz5aP/USPkkKXQiyUqm0oEev8RcBM= =XAIE -----END PGP SIGNATURE-----