| ... | @@ -133,6 +133,11 @@ fn getRandomBytesDevURandom(buf: []u8) !void { | ... | @@ -133,6 +133,11 @@ fn getRandomBytesDevURandom(buf: []u8) !void { |
| 133 | const fd = try openC(c"/dev/urandom", O_RDONLY | O_CLOEXEC, 0); | 133 | const fd = try openC(c"/dev/urandom", O_RDONLY | O_CLOEXEC, 0); |
| 134 | defer close(fd); | 134 | defer close(fd); |
| 135 | | 135 | |
| | 136 | const st = try fstat(fd); |
| | 137 | if (!S_ISCHR(st.mode)) { |
| | 138 | return OpenError.Unexpected; |
| | 139 | } |
| | 140 | |
| 136 | const stream = &std.fs.File.openHandle(fd).inStream().stream; | 141 | const stream = &std.fs.File.openHandle(fd).inStream().stream; |
| 137 | stream.readNoEof(buf) catch return error.Unexpected; | 142 | stream.readNoEof(buf) catch return error.Unexpected; |
| 138 | } | 143 | } |