[Webkit-unassigned] [Bug 146473] Errors in read() are not handled in WTF::cryptographicallyRandomValuesFromOS.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Jun 30 16:09:54 PDT 2015
https://bugs.webkit.org/show_bug.cgi?id=146473
--- Comment #12 from Keith Miller <keith_miller at apple.com> ---
Comment on attachment 255869
--> https://bugs.webkit.org/attachment.cgi?id=255869
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=255869&action=review
>> Source/WTF/wtf/OSRandomSource.cpp:67
>> + if (currentRead < 0 && !(errno == EAGAIN || errno == EINTR))
>
> I think it would be nicer to check for -1 explicitly, rather than implicitly by including all negatives in the test. The documentation states that read will return -1, 0, or a positive number, and it is nice to be precise.
>
> You can simplify the logic here a bit and avoid testing currentRead twice like so:
>
> if (currentRead == -1) {
> if (!(errno == EAGAIN || errno == EINTR))
> crashUnableToReadFromURandom();
> } else
> amountRead += currentRead;
>
> This helps to clearly separate the failure case from the success case.
That makes sense. Do you think the code you wrote is clearer than:
if (currentRead >= 0)
amountRead += currentRead;
else if (!(errno == EAGAIN || errno == EINTR))
crashUnableToReadFromURandom();
I guess it depends on whether or not you think about the success or failure case first. It also, doesn't make the -1 condition explicit.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150630/94e15849/attachment.html>
More information about the webkit-unassigned
mailing list