mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 16:04:15 +01:00
bandb: sqlite3: check read() return value
This commit is contained in:
parent
08006c16f8
commit
20b940a99c
1 changed files with 7 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue