[PATCH] [libc++] Don't return uninitialized data from random_device::operator()

David Majnemer david.majnemer at gmail.com
Tue May 27 11:44:40 PDT 2014


I've added a test for the EOF case.

I have written a test for EINTR case but I did not included it because it's
inherently not reliable. It checks the output of operator() to see if
signals resulted in us getting a lot of zero return results.


On Tue, May 27, 2014 at 7:45 AM, Marshall Clow <mclow.lists at gmail.com>wrote:

>
> On May 20, 2014, at 2:25 AM, David Majnemer <david.majnemer at gmail.com>
> wrote:
>
> Oops, sent out the wrong version of this patch.  Attached is what I
> intended to send.
>
>
> On Tue, May 20, 2014 at 12:28 AM, David Majnemer <david.majnemer at gmail.com
> > wrote:
>
>> random_device::operator() as currently implemented does not correctly
>> handle errors returned by read.  This can result in it returning
>> uninitialized data.
>>
>> To fix this, wrap the call to read in a loop.
>>
>
> I like this; but can you think of any way to test it?
>
> — Marshall
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140527/ea95b85d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140527/ea95b85d/attachment.obj>


More information about the cfe-commits mailing list