blob: 367ec16f4309f51149b9788951b87dff2ca8e076 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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;
}
|