SQLite

Check-in [6d258c3c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the ".read" command so that it gives an error when its argument is a directory. See forum message 4c53c434ca.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6d258c3c7ecafa1114e4a63739971ff527580868659c2f2c47d2c0adb92c1453
User & Date: drh 2020-07-20 23:33:11
Context
2020-07-21
18:25
Add the sqlite3Int64ToText() routine and use it to convert integers to text, as it is much faster than the generic text formatter. (check-in: 14eed318 user: drh tags: trunk)
2020-07-20
23:33
Fix the ".read" command so that it gives an error when its argument is a directory. See forum message 4c53c434ca. (check-in: 6d258c3c user: drh tags: trunk)
18:07
Fix a corner-case error in the new UPDATE FROM logic helpfully discovered by OSSFuzz. (check-in: 5cc20093 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

619
620
621
622
623
624
625















626
627
628
629
630
631
632
  int n = 0;
  while( *z ){
    if( (0xc0&*(z++))!=0x80 ) n++;
  }
  return n;
}
















/*
** This routine reads a line of text from FILE in, stores
** the text in memory obtained from malloc() and returns a pointer
** to the text.  NULL is returned at end of file, or if malloc()
** fails.
**
** If zLine is not NULL then it is a malloced buffer returned from







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
  int n = 0;
  while( *z ){
    if( (0xc0&*(z++))!=0x80 ) n++;
  }
  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
** to the text.  NULL is returned at end of file, or if malloc()
** fails.
**
** If zLine is not NULL then it is a malloced buffer returned from
8928
8929
8930
8931
8932
8933
8934

8935
8936
8937
8938
8939
8940
8941
8942
8943
    FILE *inSaved = p->in;
    int savedLineno = p->lineno;
    if( nArg!=2 ){
      raw_printf(stderr, "Usage: .read FILE\n");
      rc = 1;
      goto meta_command_exit;
    }

    p->in = fopen(azArg[1], "rb");
    if( p->in==0 ){
      utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
      rc = 1;
    }else{
      rc = process_input(p);
      fclose(p->in);
    }
    p->in = inSaved;







>
|
|







8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
    FILE *inSaved = p->in;
    int savedLineno = p->lineno;
    if( nArg!=2 ){
      raw_printf(stderr, "Usage: .read FILE\n");
      rc = 1;
      goto meta_command_exit;
    }
    if( notNormalFile(azArg[1])
     || (p->in = fopen(azArg[1], "rb"))==0
    ){
      utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
      rc = 1;
    }else{
      rc = process_input(p);
      fclose(p->in);
    }
    p->in = inSaved;