From: mistachkin Date: Fri, 6 Sep 2013 20:30:53 +0000 (+0000) Subject: When converting from a BLOB value in the tointeger() and toreal() SQL functions,... X-Git-Tag: version-3.8.1~11^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a5b271908e1f934e2cd3db2e62ad2a0eddbc624;p=thirdparty%2Fsqlite.git When converting from a BLOB value in the tointeger() and toreal() SQL functions, make sure that endianness of the machine does not matter. FossilOrigin-Name: 94c4cdc50d2753c859e494d53cebd09edd2e5663 --- diff --git a/manifest b/manifest index 39884a7204..6da51c9843 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\stest\scases\sfor\sthe\stointeger()\sand\storeal()\sSQL\sfunctions\swhen\sconverting\sfrom\sa\sBLOB. -D 2013-09-04T00:58:00.238 +C When\sconverting\sfrom\sa\sBLOB\svalue\sin\sthe\stointeger()\sand\storeal()\sSQL\sfunctions,\smake\ssure\sthat\sendianness\sof\sthe\smachine\sdoes\snot\smatter. +D 2013-09-06T20:30:53.365 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c 2317c814866d9aa71fea16b3faf4fdd4d6a49b94 F src/expr.c 4d89bd03a04fcdb5ff71d86b4e0cc7d3230797b8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb -F src/func.c ed294cd9437881cb7e2fbece2ea3389fc80c9fc7 +F src/func.c 1f24db7b0f19e28170ffa5d5887b842e4d9a48d9 F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -562,7 +562,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test 488c8deabf6a282e47aa5fcde782c6657e7625bc +F test/func4.test 142490571f2e7ee6c3c5a65f24cad3f8342c02a2 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1110,7 +1110,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 2982725e12715fba425a46ae024f317f031b6a54 -R c95b9007057313a186c90146fdfe015a +P e1814452faa698946ef77f06a42665277ee59cc1 +R 134c8f8ed3149356b5cf5475063a56e8 U mistachkin -Z e95b03ef226de372c05086e066827ed5 +Z b7db7274557533e42de3d2876d1a3f58 diff --git a/manifest.uuid b/manifest.uuid index c24c8842e5..95adfb0cad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1814452faa698946ef77f06a42665277ee59cc1 \ No newline at end of file +94c4cdc50d2753c859e494d53cebd09edd2e5663 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 31b96d4a9c..7c6c6b26b0 100644 --- a/src/func.c +++ b/src/func.c @@ -966,8 +966,8 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ } /* -** tointeger(X): If X is any value (integer, double, or string) that can -** be losslessly converted into an integer, then make the conversion and +** tointeger(X): If X is any value (integer, double, blob, or string) that +** can be losslessly converted into an integer, then make the conversion and ** return the result. Otherwise, return NULL. */ static void tointegerFunc( @@ -996,7 +996,16 @@ static void tointegerFunc( int nBlob = sqlite3_value_bytes(argv[0]); if( nBlob==sizeof(i64) ){ i64 iVal; - memcpy(&iVal, zBlob, sizeof(i64)); + if( SQLITE_BIGENDIAN ){ + int i; + unsigned char *zBlobRev = contextMalloc(context, nBlob); + if( !zBlobRev ) break; + for(i=0; i