Hi Alejandro, Alejandro Colomar wrote on Sun, Jan 01, 2023 at 01:08:17AM +0100: > On 12/31/22 20:08, Alejandro Colomar wrote:
>> This makes the code much more readable and self-documented. While doing >> this, I noticed a few bugs, and other cases which may be bugs or not. >> Switching to this specialized API makes it easier to spot such bugs, but >> since I'm not familiar with the code, I kept some bugs unfixed. The >> most obvious ones (although I may be wrong) I fixed them. And in some >> cases where it was very unclear, I didn't touch the old *_uniform() code. >> >> Below are the cases where I changed the behavior (I considered it a bug): >> >> * usr.bin/ssh/auth.c: >> >> - *cp = hashchars[arc4random_uniform(sizeof(hashchars) - 1)]; >> + *cp = hashchars[arc4random_range(0, sizeof(hashchars) - 1)]; > Reconsidering, this one is probably better just as > arc4random_uniform(sizeof(hashchars)). That seems to introduce exactly the same bug as your first try. I already explained last year that the code is correct as-is. We don't want NUL bytes in the password hash, hence the - 1. Also, please avoid using MIME when you post to OpenBSD lists, with the only exception of posting tarballs of new ports to ports@, in which case attachments are OK. Yours, Ingo