]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the ".read" command so that it gives an error when its argument is
authordrh <drh@noemail.net>
Mon, 20 Jul 2020 23:33:11 +0000 (23:33 +0000)
committerdrh <drh@noemail.net>
Mon, 20 Jul 2020 23:33:11 +0000 (23:33 +0000)
a directory.
See [https://sqlite.org/forum/forumpost/4c53c434ca|forum message 4c53c434ca].

FossilOrigin-Name: 6d258c3c7ecafa1114e4a63739971ff527580868659c2f2c47d2c0adb92c1453

manifest
manifest.uuid
src/shell.c.in

index 6d0802502ae3d9df1d732f28ed859866664409b2..1c0d2b40b65199aeff80e5e61492208c59dc29fc 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,6 +1,6 @@
 B 7a876209a678a34c198b54ceef9e3c041f128a14dc73357f6a57cadadaa6cf7b
-C Fix\sa\scorner-case\serror\sin\sthe\snew\sUPDATE\sFROM\slogic\shelpfully\sdiscovered\nby\sOSSFuzz.
-D 2020-07-20T18:07:35.022
+C Fix\sthe\s".read"\scommand\sso\sthat\sit\sgives\san\serror\swhen\sits\sargument\sis\na\sdirectory.\nSee\s[https://sqlite.org/forum/forumpost/4c53c434ca|forum\smessage\s4c53c434ca].
+D 2020-07-20T23:33:11.707
 F Makefile.in 19374a5db06c3199ec1bab71ab74a103d8abf21053c05e9389255dc58083f806
 F Makefile.msc 48f5a3fc32672c09ad73795749f6253e406a31526935fbbffd8f021108d54574
 F autoconf/Makefile.am a8d1d24affe52ebf8d7ddcf91aa973fa0316618ab95bb68c87cabf8faf527dc8
@@ -29,7 +29,7 @@ F src/pragma.c ae499b5ab8f4e833f67e28bf2322500e9aa612aadf12581d1324333f848d8b51
 F src/pragma.h 8dc78ab7e9ec6ce3ded8332810a2066f1ef6267e2e03cd7356ee00276125c6cf
 F src/resolve.c 2dd6821aac2cd27de9fcf6aa6d1f8c41b4b5841c9bc58bf1c9109008009a3a2e
 F src/select.c 39c6b63d996f9a24b34d2ccf38f67a7283355056011c2bb1b135daed7a715cf5
-F src/shell.c.in 81fa23ac1a3d6ac9ed13e9ae711a3d8806396ca7cc12c5d6a2e2536f70b0c7ad
+F src/shell.c.in 352a0a6399ccae40a30f72ea06f52f3791a062bde9b8929a97f345e1584ba310
 F src/sqliteInt.h 9682c3ce6b970b3a997d65c140bdb5b286a04188e4e1c8489b64a525161ecb30
 F src/test1.c fe56c4bcaa2685ca9aa25d817a0ee9345e189aff4a5a71a3d8ba946c7776feb8
 F src/test_malloc.c 21121ea85b49ec0bdb69995847cef9036ef9beca3ce63bbb776e4ea2ecc44b97
@@ -70,7 +70,7 @@ F tool/mksqlite3c.tcl f4ef476510eca4124c874a72029f1e01bc54a896b1724e8f9eef0d8bfa
 F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf
 F tool/showlocks.c 9cc5e66d4ebbf2d194f39db2527ece92077e86ae627ddd233ee48e16e8142564
 F tool/speed-check.sh 615cbdf50f1409ef3bbf9f682e396df80f49d97ed93ed3e61c8e91fae6afde58
-P de2a90812498e504c9b8eeb83bfc48a948b45e87bdfa242c0aa9f0377d90740f
-R 63d0c6e2d5ef247c5f1458f1099377ab
+P 5cc200939d3a33566ddb858fc74c878acc72cfe5cf4c9b1d08e7b13e4d5ff566
+R 31bbfdd93c9215857f0fa05ed289844e
 U drh
-Z b970f4086adbbc294d690e39a6ac70c0
+Z 4ed324ec08dc243e01ea3575725217a0
index 14915032f7ea3e6e4fef22211a0a735a1e920c0c..dc3e5ac416ed60c84f6e75bb2e9a8d5e6fbb7632 100644 (file)
@@ -1 +1 @@
-5cc200939d3a33566ddb858fc74c878acc72cfe5cf4c9b1d08e7b13e4d5ff566
\ No newline at end of file
+6d258c3c7ecafa1114e4a63739971ff527580868659c2f2c47d2c0adb92c1453
\ No newline at end of file
index 78a80da3e9fd71de2110e3217de804e942ef3e57..ee0bc82beca1b09103509d895869644a19fa6523 100644 (file)
@@ -623,6 +623,21 @@ static int strlenChar(const char *z){
   return n;
 }
 
+/*
+** Return true if zFile does not exist or if it is not an ordinary file.
+*/
+#ifdef _WIN32
+# define notNormalFile(X) 0
+#else
+static int notNormalFile(const char *zFile){
+  struct stat x;
+  int rc;
+  memset(&x, 0, sizeof(x));
+  rc = stat(zFile, &x);
+  return rc || !S_ISREG(x.st_mode);
+}
+#endif
+
 /*
 ** This routine reads a line of text from FILE in, stores
 ** the text in memory obtained from malloc() and returns a pointer
@@ -8932,8 +8947,9 @@ static int do_meta_command(char *zLine, ShellState *p){
       rc = 1;
       goto meta_command_exit;
     }
-    p->in = fopen(azArg[1], "rb");
-    if( p->in==0 ){
+    if( notNormalFile(azArg[1])
+     || (p->in = fopen(azArg[1], "rb"))==0
+    ){
       utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
       rc = 1;
     }else{