diff --git a/bandb/sqlite3.c b/bandb/sqlite3.c index dcb28280..0e59fd6e 100644 --- a/bandb/sqlite3.c +++ b/bandb/sqlite3.c @@ -23422,8 +23422,14 @@ unixRandomness(sqlite3_vfs * pVfs, int nBuf, char *zBuf) #if !defined(SQLITE_TEST) { int pid, fd; + int len = 0; fd = open("/dev/urandom", O_RDONLY); - if(fd < 0) + if(fd >= 0) + { + len = read(fd, zBuf, nBuf); + close(fd); + } + if(len < nBuf) { time_t t; time(&t); @@ -23431,11 +23437,6 @@ unixRandomness(sqlite3_vfs * pVfs, int nBuf, char *zBuf) pid = getpid(); memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid)); } - else - { - read(fd, zBuf, nBuf); - close(fd); - } } #endif return SQLITE_OK;