Fix the ".read" command so that it gives an error when its argument is
a directory. See [https://sqlite.org/forum/forumpost/4c53c434ca|forum message 4c53c434ca]. FossilOrigin-Name: 6d258c3c7ecafa1114e4a63739971ff527580868659c2f2c47d2c0adb92c1453
This commit is contained in:
+18
-2
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user