[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-dev
Subject:    Re: [sqlite-dev] '.open --hexdb' in interactive shell: Segmentation fault
From:       Arfrever Frehtes Taifersar Arahesis <arfrever.fta () gmail ! com>
Date:       2019-05-03 20:04:13
Message-ID: 201905032204.20753.Arfrever.FTA () gmail ! com
[Download RAW message or body]

https://sqlite.org/src/info/9b5d943426c92731 does not really make
'.open --hexdb' work in sqlite3 interactive shell.

Before https://sqlite.org/src/info/9b5d943426c92731, after writing
'.open --hexdb' and pressing Enter, segmentation fault occurs immediately.

Since https://sqlite.org/src/info/9b5d943426c92731, after writing
'.open --hexdb' and pressing Enter:
- If writing nothing or random incorrect text and pressing Ctrl+D (end of file),
  segmentation fault occurs.
- If writing correct output from dbtotxt tool and pressing Enter:
  - If SQLite has been built with support for Readline ('./configure \
--enable-readline --disable-editline'),  "buffer overflow detected" error and \
                abortion occurs.
  - If SQLite has been built without support for Readline ('./configure \
--disable-readline --disable-editline'),  sqlite3 process exits immediately with exit \
code 0.

I use Readline 8.0.

Outputs for SQLite built with support for Readline:

$ ./sqlite3
SQLite version 3.29.0 2019-05-03 17:19:10
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open --hexdb
Segmentation fault


$ gdb ./sqlite3
...
(gdb) r
...
SQLite version 3.29.0 2019-05-03 17:19:10
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open --hexdb

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7d37992 in fgets () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7d37992 in fgets () from /lib64/libc.so.6
#1  0x000055555556cb0b in fgets (__stream=<optimized out>, __n=1000, \
__s=0x7fffffffad90 "\003") at /usr/include/bits/stdio2.h:265 #2  readHexDb \
(p=0x7fffffffcae0, pnData=0x7fffffffb1c4) at shell.c:12422 #3  0x0000555555579b9d in \
open_db (p=0x7fffffffcae0, openFlags=1) at shell.c:12659 #4  0x0000555555582e62 in \
open_db (openFlags=1, p=0x7fffffffcae0) at shell.c:16296 #5  do_meta_command \
(zLine=<optimized out>, p=0x7fffffffcae0) at shell.c:16311 #6  0x0000555555583631 in \
process_input (p=0x7fffffffcae0) at shell.c:17968 #7  0x00005555555621e1 in main \
(argc=<optimized out>, argv=<optimized out>) at shell.c:18754


$ ./sqlite3
SQLite version 3.29.0 2019-05-03 17:19:10
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open --hexdb
> size 4096 pagesize 4096 filename a.db
> page 1 offset 0
> 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
> 16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 01   .....@  ........
> 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
> 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
> 96: 00 2e 38 08 0d 00 00 00 00 10 00 00 00 00 00 00   ..8.............
> end a.db
sqlite> *** buffer overflow detected ***: ./sqlite3 terminated
Aborted


$ gdb ./sqlite3
...
(gdb) r
...
SQLite version 3.29.0 2019-05-03 17:19:10
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open --hexdb
> size 4096 pagesize 4096 filename a.db
> page 1 offset 0
> 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
> 16: 10 00 01 01 00 40 20 20 00 00 00 01 00 00 00 01   .....@  ........
> 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
> 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01   ................
> 96: 00 2e 38 08 0d 00 00 00 00 10 00 00 00 00 00 00   ..8.............
> end a.db
sqlite> *** buffer overflow detected ***: /tmp/sqlite/sqlite3 terminated

Program received signal SIGABRT, Aborted.
0x00007ffff7cfba2b in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7cfba2b in raise () from /lib64/libc.so.6
#1  0x00007ffff7ce453d in abort () from /lib64/libc.so.6
#2  0x00007ffff7d43549 in ?? () from /lib64/libc.so.6
#3  0x00007ffff7de1a85 in ?? () from /lib64/libc.so.6
#4  0x00007ffff7de1ac3 in __fortify_fail () from /lib64/libc.so.6
#5  0x00007ffff7ddfbc2 in __chk_fail () from /lib64/libc.so.6
#6  0x00007ffff7de1932 in __fdelt_warn () from /lib64/libc.so.6
#7  0x00007ffff7f88ee3 in rl_getc () from /lib64/libreadline.so.8
#8  0x00007ffff7f899f9 in rl_read_key () from /lib64/libreadline.so.8
#9  0x00007ffff7f6bb30 in readline_internal_char () from /lib64/libreadline.so.8
#10 0x00007ffff7f6c4bd in readline () from /lib64/libreadline.so.8
#11 0x0000555555583482 in one_input_line (isContinuation=<optimized out>, \
zPrior=0x5555556a8bb0 "\260\231nUUU", in=0x0) at shell.c:656 #12 process_input \
(p=0x7fffffffcae0) at shell.c:17950 #13 0x00005555555621e1 in main (argc=<optimized \
out>, argv=<optimized out>) at shell.c:18754

--
Arfrever Frehtes Taifersar Arahesis
_______________________________________________
sqlite-dev mailing list
sqlite-dev@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic