Fossil SCM
Fix problems with the built-in "decompress()" SQL function.
Commit
449ab5d6003c78ecd3014bf4ad6695703f2b54d6e6653a54aeffcc8d30ddd91c
Parent
ecf679b28956ccb…
1 file changed
+3
+3
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -110,12 +110,15 @@ | ||
| 110 | 110 | unsigned int nIn; |
| 111 | 111 | unsigned long int nOut; |
| 112 | 112 | int rc; |
| 113 | 113 | |
| 114 | 114 | pIn = sqlite3_value_blob(argv[0]); |
| 115 | + if( pIn==0 ) return; | |
| 115 | 116 | nIn = sqlite3_value_bytes(argv[0]); |
| 117 | + if( nIn<4 ) return; | |
| 116 | 118 | nOut = (pIn[0]<<24) + (pIn[1]<<16) + (pIn[2]<<8) + pIn[3]; |
| 119 | + if( nOut<0 ) return; | |
| 117 | 120 | pOut = sqlite3_malloc( nOut+1 ); |
| 118 | 121 | rc = uncompress(pOut, &nOut, &pIn[4], nIn-4); |
| 119 | 122 | if( rc==Z_OK ){ |
| 120 | 123 | sqlite3_result_blob(context, pOut, nOut, sqlite3_free); |
| 121 | 124 | }else if( rc==Z_MEM_ERROR ){ |
| 122 | 125 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -110,12 +110,15 @@ | |
| 110 | unsigned int nIn; |
| 111 | unsigned long int nOut; |
| 112 | int rc; |
| 113 | |
| 114 | pIn = sqlite3_value_blob(argv[0]); |
| 115 | nIn = sqlite3_value_bytes(argv[0]); |
| 116 | nOut = (pIn[0]<<24) + (pIn[1]<<16) + (pIn[2]<<8) + pIn[3]; |
| 117 | pOut = sqlite3_malloc( nOut+1 ); |
| 118 | rc = uncompress(pOut, &nOut, &pIn[4], nIn-4); |
| 119 | if( rc==Z_OK ){ |
| 120 | sqlite3_result_blob(context, pOut, nOut, sqlite3_free); |
| 121 | }else if( rc==Z_MEM_ERROR ){ |
| 122 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -110,12 +110,15 @@ | |
| 110 | unsigned int nIn; |
| 111 | unsigned long int nOut; |
| 112 | int rc; |
| 113 | |
| 114 | pIn = sqlite3_value_blob(argv[0]); |
| 115 | if( pIn==0 ) return; |
| 116 | nIn = sqlite3_value_bytes(argv[0]); |
| 117 | if( nIn<4 ) return; |
| 118 | nOut = (pIn[0]<<24) + (pIn[1]<<16) + (pIn[2]<<8) + pIn[3]; |
| 119 | if( nOut<0 ) return; |
| 120 | pOut = sqlite3_malloc( nOut+1 ); |
| 121 | rc = uncompress(pOut, &nOut, &pIn[4], nIn-4); |
| 122 | if( rc==Z_OK ){ |
| 123 | sqlite3_result_blob(context, pOut, nOut, sqlite3_free); |
| 124 | }else if( rc==Z_MEM_ERROR ){ |
| 125 |