0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 00:14:07 +01:00

Merge pull request #146 from lp0/fix-sqlite-unixRandomness-read-20160211

bandb: sqlite3: check read() return value
This commit is contained in:
William Pitcock 2016-02-11 16:13:34 -06:00
commit 7b20f46ed3

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;