Initialize the random number generator from /dev/urandom, if available. (CVS 2258)

FossilOrigin-Name: aab8e7f8d81ffa786d5fae5a13963c6e58a8eefc
This commit is contained in:
drh 2005-01-21 17:53:17 +00:00
parent 0602c2e4a5
commit 842b864118
3 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Change\sto\smkopcodeh.awk\sto\saccomodate\swindows\ssystems.\s(CVS\s2257) C Initialize\sthe\srandom\snumber\sgenerator\sfrom\s/dev/urandom,\sif\savailable.\s(CVS\s2258)
D 2005-01-21T17:07:23 D 2005-01-21T17:53:17
F Makefile.in ffd81f5e926d40b457071b4de8d7c1fa18f39b5a F Makefile.in ffd81f5e926d40b457071b4de8d7c1fa18f39b5a
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@ -48,7 +48,7 @@ F src/os.h ae44064dc118b20d39450cb331409a775e8bb1c6
F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73 F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73
F src/os_test.c 91e5f22dd89491e5e1554820e715805f43fa4ece F src/os_test.c 91e5f22dd89491e5e1554820e715805f43fa4ece
F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162 F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162
F src/os_unix.c 77319e31f5284c5714239cf50ae28552286414df F src/os_unix.c 1f17ceff056c64939e5f2e98bf909fc64d0929ca
F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13 F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13
F src/os_win.c 3c0b0a3bc33318cf555a1cd130232ad1b9a5a711 F src/os_win.c 3c0b0a3bc33318cf555a1cd130232ad1b9a5a711
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
@ -271,7 +271,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl 3e522a06ad41992023c80ca29a048ae2331ca5bd F www/whentouse.tcl 3e522a06ad41992023c80ca29a048ae2331ca5bd
P 4d9b858746084c2636ba618108775b9be2eff0a5 P 39786aa894d620480661ed8867961f9f1ef33e40
R b294ab96a83b2891d9812a17ce9a70c9 R 3b3cb6465646de5c987cef2f82ee9d6f
U drh U drh
Z 4c64a14703470895094994113ac63b9b Z 55ddc61929d4f52f311fda35960362e7

View File

@ -1 +1 @@
39786aa894d620480661ed8867961f9f1ef33e40 aab8e7f8d81ffa786d5fae5a13963c6e58a8eefc

View File

@ -1183,10 +1183,16 @@ int sqlite3OsRandomSeed(char *zBuf){
memset(zBuf, 0, 256); memset(zBuf, 0, 256);
#if !defined(SQLITE_TEST) #if !defined(SQLITE_TEST)
{ {
int pid; int pid, fd;
time((time_t*)zBuf); fd = open("/dev/urandom", O_RDONLY);
pid = getpid(); if( fd<0 ){
memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid)); time((time_t*)zBuf);
pid = getpid();
memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid));
}else{
read(fd, zBuf, 256);
close(fd);
}
} }
#endif #endif
return SQLITE_OK; return SQLITE_OK;