<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
I tried to report this issue one week ago through RT, but failed somehow.
<div>I didn't insist because I then noticed that the issue had already been reported as:</div>
<div><a href="https://rt.openssl.org/Ticket/Display.html?user=guest&pass=guest&id=3159">https://rt.openssl.org/Ticket/Display.html?user=guest&pass=guest&id=3159</a></div>
<div><br>
</div>
<div>However, the patch provided in that report makes some unrelated changes.</div>
<div><br>
</div>
<div>A better candidate for a patch should be the one I attach.</div>
<div><br>
</div>
<div>In the first chunk, the function being patched, ssleay_rand_add, returns</div>
<div>void. Therefore a choice should be made between returning when</div>
<div>failure is detected or calling abort(). Note that the current behavior</div>
<div>when MD_init fails is to dereference a null pointer a few instructions</div>
<div>later, so that calling abort() would not be a loss of functionality (but</div>
<div>it would improve the safety of the code. Dereferencing a null pointer</div>
<div>is undefined behavior and is not guaranteed to crash the program).</div>
<div><br>
</div>
<div>The remaining chunks patch the function ssleay_rand_bytes, which</div>
<div>has a convention to signaling errors through a return code, documented at:</div>
<div><a href="https://www.openssl.org/docs/crypto/RAND_bytes.html">https://www.openssl.org/docs/crypto/RAND_bytes.html</a></div>
<div><br>
</div>
<div>The patch makes the function return 0 in case of allocation failure,</div>
<div>which seems to best match the existing documented cases:</div>
<div><br>
</div>
<div>“RAND_bytes() returns 1 on success, 0 otherwise.</div>
<div>The error code can be obtained by ERR_get_error.</div>
<div>RAND_pseudo_bytes() returns 1 if the bytes generated are cryptographically strong,</div>
<div>0 otherwise.</div>
<div>Both functions return -1 if they are not supported by the current RAND method.”</div>
<div><br>
</div>
<div>Pascal Cuoq</div>
<div>TrustInSoft Chief Scientist</div>
<div><br>
</div>
<div></div>
</body>
</html>