Skip to content

Commit 1ecb9d7

Browse files
dmitry-starodubovAlexPeshkoff
authored andcommitted
Check for an error when opening "/dev/urandom". Otherwise wrong error is returned e.g. if the open file limit is reached.
1 parent 1833922 commit 1ecb9d7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/common/os/posix/guid.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ void GenerateRandomBytes(void* buffer, FB_SIZE_T size)
4545
{
4646
// do not use /dev/random because it may return lesser data than we need.
4747
int fd = os_utils::open("/dev/urandom", O_RDONLY);
48+
if (fd < 0)
49+
Firebird::system_call_failed::raise("open");
50+
4851
for (FB_SIZE_T offset = 0; offset < size; )
4952
{
5053
int rc = read(fd, static_cast<char*>(buffer) + offset, size - offset);

0 commit comments

Comments
 (0)