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

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

On 2026-04-20T07:04:02+0800, Kevin J. McCarthy wrote:
> 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.

Oh, I had misread and confused MD_DIGEST_LEN by MD5_BLOCK_LEN, and
thought there was only one size being used everywhere.  Yup; please
discard my patch.

I'll have another look today.


Cheers,
Alex

> 
> -- 
> Kevin J. McCarthy
> GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA



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

iQIyBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmnl92MACgkQ64mZXMKQ
wqlSbQ/48hddGTm7JEQHhkIa/JoxvOroCvu834GeEik7h6bdiEznmqS0ym+pL0wl
CmC8nOBYj7nqlBthXE2P98VGSwlLmPujws6mcy6pLwHhka53w7CkrYbPnHuQmiGq
NyMKHbzqQUH1zRIY5xtR9mcME1EvxOCgGt+GnJcqB8AOpChCaocJ7UoF/OFozuDi
cqpEbPIEEkHQkatCqZnQkH4gMkTNORiFy7RFWhKl82WTnjSPl72DkonUCSrm7DuY
Lt/PZ6+dOTrX/HygfhU2uLYngRUaRW5J/NoJKOBxq0RG07R0rPnY1pmFk3Gcgi6P
+ItuqWZQF0I/+gJkhLyi6IMA+8bQxrkVgAXybD98y7+5nd+RxhB/Bv1QaeUG2U7/
kZcS54HfEVCF2NTeSzon8MhAffq1F0nfge5vG8FkObMPbIFlbDP9h4INoCcpJYVm
rB/q90ZrpymBOLR/1ezdUkcP/ys1ZMPP6iSIntRvMGchQ+9x1Xw3jeD3TQ0jm6BC
r7pmV/yMV8+bqODX44V9sHE9vzBLu1RaKBlcSJ+EBbnbLD7L1gK3XqqLX+H8o16z
b8KfXWLbVZagqJnmLxguVhGVM8a6MLD95mzU7R8NRytPktE9xU8XNhYm3uw85yVo
7H9bh/sZvSCiNx3sAo9mgJ9nW7NoHJ6JcDGwmsNi0GEkr63tRw==
=ba4c
-----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.