From: drh <> Date: Tue, 25 Oct 2022 13:46:38 +0000 (+0000) Subject: Fix the ".dump" command in the CLI so that it is more rebust against X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4522957c730755aac6336ef49263ade575006deb;p=thirdparty%2Fsqlite.git Fix the ".dump" command in the CLI so that it is more rebust against corrupt database files. At the same time, enhance the sqlite3_strglob() and sqlite3_strlike() interfaces so that they will do sensible things with NULL string pointers. FossilOrigin-Name: 681c85ef698b2571028ac0698451fb4819c2d49dbea42a66c53140f5a34d8608 --- diff --git a/manifest b/manifest index 6b4f23f7a0..ae0a5c34df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\scall\sto\sstrlen()\swith\sa\snull\sargument\sin\sthe\scommand-line\sshell\nfollowing\san\sOOM\serror.\s[forum:/forumpost/9c4f2ebe22|forum\spost\s9c4f2ebe22]. -D 2022-10-17T16:29:08.865 +C Fix\sthe\s".dump"\scommand\sin\sthe\sCLI\sso\sthat\sit\sis\smore\srebust\sagainst\ncorrupt\sdatabase\sfiles.\s\sAt\sthe\ssame\stime,\nenhance\sthe\ssqlite3_strglob()\sand\ssqlite3_strlike()\sinterfaces\sso\sthat\sthey\nwill\sdo\ssensible\sthings\swith\sNULL\sstring\spointers. +D 2022-10-25T13:46:38.891 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -524,7 +524,7 @@ F src/delete.c a8e844af211a48b13b5b358be77a12c860c6a557c21990ad51a548e2536500ce F src/expr.c 4907afcb86d72b5525d8767515ce425ec53c7a2d3664441b46cef5b376ee0cba F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d965ede15d8360c09ed59348940649ee647b192e784466837d7aefa836d1d91e -F src/func.c 8f72e88cccdee22185133c10f96ccd61dc34c5ea4b1fa9a73c237ef59b2e64f1 +F src/func.c 8b7ac5934fa3dde84ce1fcb82824cb26366097adb91a6739644b7686cc3750ff F src/global.c e83ee571b79ee3adc32e380cf554cf1254bc43763d23786c71721fbcdfbbb965 F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -571,7 +571,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c F src/resolve.c f0d663c9b1ceeb3e7d262ede872dd3b24b323a7cc11d84c05a39d962e7d64b07 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c fea5ae26259dc995b2144a28bbb5b013196dbcc86527cd992ed109b00af7f9e8 -F src/shell.c.in a577c479629d26106fdf5d957615f4da3fb1b76600b81544803998b7de39f656 +F src/shell.c.in 72592006128234030e0adc70c35fb5581604e3a0781e128beebbe095ad7cb0a3 F src/sqlite.h.in 01573eae96721f2a8ee2a9e3b7140ceeba2e9c44350911890b89b8ff0dcf6781 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d @@ -1980,9 +1980,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 835e191213acd3b357b912469078c01796f6119d80a56950dab95ab704eb2f87 -Q +b6413a6dff8ac9b7088b1381afbbbf799e376455d11786530cc5fc825747ab53 -R 32319aab5f9f51cafa211fffa0abfca9 +P 67bb8eda73d292edd5be0d02ef12d4a77d7146251098171465efd88d2169105c +Q +0573edfb9e0b1fd51e8da20592c71b02040968c33fdec41c31a6b1b7d3e83262 +Q +8ba9c884bded52e3e044ff39c826c04838e7c31f05d802f4a14d9ce5a01ab721 +R 5ee9a7b2581706a08e2a9b1e0ad67887 U drh -Z d82e7818ba23665d6a49fc33e24bea18 +Z 55a77b4f72e9454c1fb0f3248888c2d2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 10da40883c..146cf3a817 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67bb8eda73d292edd5be0d02ef12d4a77d7146251098171465efd88d2169105c \ No newline at end of file +681c85ef698b2571028ac0698451fb4819c2d49dbea42a66c53140f5a34d8608 \ No newline at end of file diff --git a/src/func.c b/src/func.c index ec50a17a37..8e3cca4974 100644 --- a/src/func.c +++ b/src/func.c @@ -823,7 +823,13 @@ static int patternCompare( ** non-zero if there is no match. */ int sqlite3_strglob(const char *zGlobPattern, const char *zString){ - return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '['); + if( zString==0 ){ + return zGlobPattern!=0; + }else if( zGlobPattern==0 ){ + return 1; + }else { + return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '['); + } } /* @@ -831,7 +837,13 @@ int sqlite3_strglob(const char *zGlobPattern, const char *zString){ ** a miss - like strcmp(). */ int sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){ - return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc); + if( zStr==0 ){ + return zPattern!=0; + }else if( zPattern==0 ){ + return 1; + }else{ + return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc); + } } /* diff --git a/src/shell.c.in b/src/shell.c.in index 812a73be06..025315c78d 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4107,6 +4107,8 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){ zTable = azArg[0]; zType = azArg[1]; zSql = azArg[2]; + if( zTable==0 ) return 0; + if( zType==0 ) return 0; dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0; noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;