Blob Blame History Raw
2016-06-01  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2015-10-02  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/65142
	* src/c++11/random.cc (random_device::_M_getval()): Check read result.

--- libstdc++-v3/src/c++11/random.cc	(revision 228423)
+++ libstdc++-v3/src/c++11/random.cc	(revision 228424)
@@ -126,8 +126,10 @@ namespace std _GLIBCXX_VISIBILITY(defaul
 #endif
 
     result_type __ret;
-    std::fread(reinterpret_cast<void*>(&__ret), sizeof(result_type),
-	       1, _M_file);
+    const size_t e = std::fread(reinterpret_cast<void*>(&__ret),
+				sizeof(result_type), 1, _M_file);
+    if (e != 1)
+      std::__throw_runtime_error(__N("random_device could not be read"));
     return __ret;
   }