Merge pull request #146 from lp0/fix-sqlite-unixRandomness-read-20160211
bandb: sqlite3: check read() return value
This commit is contained in:
commit
7b20f46ed3
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)
|
#if !defined(SQLITE_TEST)
|
||||||
{
|
{
|
||||||
int pid, fd;
|
int pid, fd;
|
||||||
|
int len = 0;
|
||||||
fd = open("/dev/urandom", O_RDONLY);
|
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 t;
|
||||||
time(&t);
|
time(&t);
|
||||||
|
@ -23431,11 +23437,6 @@ unixRandomness(sqlite3_vfs * pVfs, int nBuf, char *zBuf)
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));
|
memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
read(fd, zBuf, nBuf);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
|
|
Loading…
Reference in a new issue