/ Check-in [5a56090d]
Login

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

Overview
Comment:Fix an uninitialized variable in shell.c that would cause a crash if you specified SQL on the command-line. (CVS 1238)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5a56090dde10ee29863021356d21c3f8c86e3f46
User & Date: drh 2004-02-13 20:09:42
Context
2004-02-14
01:39
Disable the malloc.test tests if not compiled with -DMEMORY_DEBUG (CVS 1239) check-in: 41b6ad78 user: drh tags: trunk
2004-02-13
20:09
Fix an uninitialized variable in shell.c that would cause a crash if you specified SQL on the command-line. (CVS 1238) check-in: 5a56090d user: drh tags: trunk
16:30
Begin the process over converting sqlite_exec() over to use sqlite_compile() and sqlite_step(). The new sqlite_exec() is still commented out. (CVS 1237) check-in: b8f2ba78 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
....
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.88 2004/02/12 20:49:36 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................
** the database fails to open, print an error message and exit.
*/
static void open_db(struct callback_data *p){
  if( p->db==0 ){
    char *zErrMsg = 0;
#ifdef SQLITE_HAS_CODEC
    int n = p->zKey ? strlen(p->zKey) : 0;
    p->db = sqlite_open_encrypted(p->zDbFilename, p->zKey, n, 0, &zErrMsg);
#else
    p->db = sqlite_open(p->zDbFilename, 0, &zErrMsg);
#endif
    if( p->db==0 ){
      if( zErrMsg ){
        fprintf(stderr,"Unable to open database \"%s\": %s\n", 
           p->zDbFilename, zErrMsg);
      }else{
        fprintf(stderr,"Unable to open database %s\n", p->zDbFilename);
................................................................................
    */
    if( zFirstCmd[0]=='.' ){
      do_meta_command(zFirstCmd, &data);
      exit(0);
    }else{
      int rc;
      open_db(&data);
      rc = sqlite_exec(db, zFirstCmd, callback, &data, &zErrMsg);
      if( rc!=0 && zErrMsg!=0 ){
        fprintf(stderr,"SQL error: %s\n", zErrMsg);
        exit(1);
      }
    }
  }else{
    /* Run commands received from standard input







|







 







|

|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
....
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.89 2004/02/13 20:09:42 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................
** the database fails to open, print an error message and exit.
*/
static void open_db(struct callback_data *p){
  if( p->db==0 ){
    char *zErrMsg = 0;
#ifdef SQLITE_HAS_CODEC
    int n = p->zKey ? strlen(p->zKey) : 0;
    db = p->db = sqlite_open_encrypted(p->zDbFilename, p->zKey, n, 0, &zErrMsg);
#else
    db = p->db = sqlite_open(p->zDbFilename, 0, &zErrMsg);
#endif
    if( p->db==0 ){
      if( zErrMsg ){
        fprintf(stderr,"Unable to open database \"%s\": %s\n", 
           p->zDbFilename, zErrMsg);
      }else{
        fprintf(stderr,"Unable to open database %s\n", p->zDbFilename);
................................................................................
    */
    if( zFirstCmd[0]=='.' ){
      do_meta_command(zFirstCmd, &data);
      exit(0);
    }else{
      int rc;
      open_db(&data);
      rc = sqlite_exec(data.db, zFirstCmd, callback, &data, &zErrMsg);
      if( rc!=0 && zErrMsg!=0 ){
        fprintf(stderr,"SQL error: %s\n", zErrMsg);
        exit(1);
      }
    }
  }else{
    /* Run commands received from standard input