Re: [PATCH v2] Improve mutt's random data generator.

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <aewnoRbUNIhRdasv@qinghai>
On Fri, Apr 24, 2026 at 04:12:26PM -0400, Kurt Hackenberg wrote:
>On Fri, Apr 24, 2026 at 13:15 +0800, Kevin J. McCarthy wrote:
>>This version switches to using ssize_t for the length parameter and
>>result from getrandom(), and thus doesn't have any unsafe casts.
>
>Good for getrandom() return value, but why for its length argument? 
>That argument is type size_t (at least on my system), and it comes 
>from an argument to mutt_random_bytes() that's also size_t.

Yeah, I started off by changing both to ssize_t.  When I rewrote the 
loop, I realized the comparison had disappeared.  But then I thought, 
eh... just leave it, as Alex pointed out, a 2^63 large number would kill 
the system anyway. :-D

>Only other use I see is
>
>    requested -= result;
>
>Whether requested is signed only matters if either variable has 
>wrapped around into negative[1], and in that case I don't see any good 
>result of that subtraction either way.

I also certainly hope the library call would never make that mistake. 
But the good news is, if it did, requested would be negative and the 
loop would end.

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

iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmnsJ6EACgkQre92hIAx
a9okFxAAhHP1Nze6b5ijfU5LBdKFJgpald8kYhop/Gve73iKKtsXKM26LcWpFNwy
ctsuU8dVb/zXJcXJNktqsY4xHt0mMCcN7m5bqTwzhKvMJwvsrC1FtrjXIiBEJxzQ
UEhdGKh3QMfj9vDzX6kjuJKcoQTBoRn2M5n6RFf0pEbyhTnj3NOfm1EkeSWMlJZW
1syd7Pty3SAeOYeD56IXAE6r5WXF221jRy645emIKVdAILPnSoRywE7IqEPdszRF
AIFzepNy0LEeDcQIe7Gw4T1jVioDYPBGfBKnwJm2Uq3G/+e+q4QlDnvZuCVt+iUx
wJ40CehM2B+Ik0o27uImkygE3Lp2dSR4y9PrcdplsNaX0E4MsB/DfImd7UgoosU5
O0vqZ9JIZLecYBsiKDj66uGKvrJg0WWTFPUKP4f66Yye8M0zuBFPKSDF1Tijh/MN
yD0gbZc8sC46uK6v31WtwRXHyL7qqF6+9Rorh81OthbYmb7aIcdvgGfD+Q8Gt+3T
u67e5eZHm23Od1oBi5RvQBlemU6J4InE3/24+JvUeumgnwdFC1LqCOslmh6yETEy
p48m9PA1RNdd4Up6sabgWwL75TS4QQ8GIPXorp2Jhp3i79V0MxIsrkt9dq/NUwzb
dQCXz+YCCNjyC5qjqBoqVQM04BP86AsQuIFTl0dcZgLt3xgJkec=
=OoMG
-----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.