Re: [PATCH v1] imap/auth_cram.c: Don't use strfcpy() where we don't want to generate a C string

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <aeVfYi8_cr8w1_IQ@qinghai>
On Sun, Apr 19, 2026 at 08:24:01PM +0200, Alejandro Colomar via Mutt-dev wrote:
>strfcpy() ensures it creates a string.  But that's not what we want.
>Here, we just want raw bytes in the output.  It's only the input which
>is a string (password).
>
>strncpy(3) is quite appropriate for this specific use.  It's a function
>that takes a C string as input, and fills a fixed-size buffer with bytes
>from it, zeroing the unused remainder part of the buffer.
>
>Because of this use of strncpy(3), we can remove the memset(3) calls.
>They're now entirely redundant.  (The other branch fills the entire
>buffer, so it was only meaningful in the branch we're touching.)

It's early and my brain isn't fully awake.  But I believe this is 
incorrect.  The other branch only fills to MD5_DIGEST_LEN.  Removing the 
memset() in that case, and copying the entire secret buffer, instead of 
secret_len, would break the algorithm.

-- 
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-----

iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmnlX2EACgkQre92hIAx
a9pnTA/8DNW1irvmsyw84ePsbhnd3g2AYxYY6IEfgOgrCxRegUzHJ8H0Orn4vCzm
Fz/9Dag4YrFer85iagikT47MrGA6AFINmwog/Q7ye+3C88mxwbsrjZFLo5WBo9gu
TkOJFsbcR4p43nvpWNpdN4zvSyGw3YWLB7USj93O9OLImpEf8U6Q16ehz7CgciO7
JLCbC4dnzVU0iFRD8ZREmRiBcMjxHwlTn+ArtC/P4R7XDQEeQvB7d/gI1HFVB8k7
IckmMmR+OkHBW45v3MoCZxEsyuU1vMOdi+Jufr1kccl1127g+fKPkYCs9ymk/IiD
ufkcQAG7jw9rCAvbsq40wugbnW7/WLXdfsZtB91/5Y3Y+kIvN/N17GYaI9TcjorB
TjJ/zWq64jeHEjpxbmD5vP6Y+CUgWhiv/U+u14Zav9xITPHlqkMzp4xjJ7FZ/rfn
M7KE2P0/+KEvSRc/fnh2atNd9AwJGP5Vyj7fVztEBEAOY3WDHhPO7DxIZw2IF0RT
ccmgSI9xixy8X0doZ/OpGncfLnkmWnGgt9fh6IPhZTqWYaJRsbdT4S/e+vTr0nTF
+LgehIqHx5oseugwzA9FqIjbwmtRrczYg3RXv4IURbkFUoA6pfxgrG1PcVCVQnou
djukH3H2Ao4OIBAeXJ7gzWb/n1iIRoc7vij4Od49PLoQqkJqpRQ=
=qS4d
-----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.