From: drh Date: Thu, 23 Feb 2006 21:51:12 +0000 (+0000) Subject: Make sure the random() function always returns a value that can be passed X-Git-Tag: version-3.6.10~3058 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=874abbed6825c7a8b112ba941a3ff6fe1680210b;p=thirdparty%2Fsqlite.git Make sure the random() function always returns a value that can be passed to abs(). (CVS 3109) FossilOrigin-Name: 5d2e7ea01989fc9ba2c79d192760bc29f8cab463 --- diff --git a/manifest b/manifest index 20eea4f7b8..7925a75ddb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Detect\sinteger\soverflow\sin\sthe\sabs()\sfunction.\s\sThe\srandom()\sfunction\nnow\sprovides\s64\sbits\sof\srandomness\sinstead\sof\sjust\s32.\s\sFix\sbugs\sin\ntesting\slogic\sof\stest4.c.\s(CVS\s3108) -D 2006-02-23T21:43:56 +C Make\ssure\sthe\srandom()\sfunction\salways\sreturns\sa\svalue\sthat\scan\sbe\spassed\nto\sabs().\s(CVS\s3109) +D 2006-02-23T21:51:13 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -43,7 +43,7 @@ F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e F src/delete.c ca404d5fd5f678e32f2f46377ad802cd0219aa99 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/expr.c 9c957fabf95ef62288151eecd5c490a629470666 -F src/func.c b1919255cef5580ac1fcd555ee9bb96974bde64d +F src/func.c 402b305b0f0d8709cce343e74312bcc38ed61f06 F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185 F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564 F src/insert.c 67b3dc11831c58d8703eb502355ad3704ee18f66 @@ -354,7 +354,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 614fac906807b8c75e04effc01666874d13ce636 -R f5403923a4dc3e33ec17bd28655d7e3e +P 942c509595a2a300e798e6b048ad7fc3bc54af43 +R 151d579d1c46dea292a923e2d9c89659 U drh -Z a926d16e02bacd004ff1a77e6671add9 +Z 630eeabb62dfd30a6a8a8d528960cacb diff --git a/manifest.uuid b/manifest.uuid index 5b67994cb1..4e30a21cff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -942c509595a2a300e798e6b048ad7fc3bc54af43 \ No newline at end of file +5d2e7ea01989fc9ba2c79d192760bc29f8cab463 \ No newline at end of file diff --git a/src/func.c b/src/func.c index be3fc943e1..e365cc435c 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.123 2006/02/23 21:43:56 drh Exp $ +** $Id: func.c,v 1.124 2006/02/23 21:51:13 drh Exp $ */ #include "sqliteInt.h" #include @@ -266,6 +266,8 @@ static void randomFunc( ){ sqlite_int64 r; sqlite3Randomness(sizeof(r), &r); + if( (r<<1)==0 ) r = 0; /* Prevent 0x8000.... as the result so that we */ + /* can always do abs() of the result */ sqlite3_result_int64(context, r); }