bandb: sqlite3: check read() return value

This commit is contained in:
Simon Arlott 2016-02-11 22:08:37 +00:00
parent 08006c16f8
commit 20b940a99c
No known key found for this signature in database
GPG key ID: BAFFFF5FF5FFAAAF

View file

@ -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;