Skip to content

libsqlcipher segfaults with openssl 1.1

debian sid, with last upgrade I started getting segfaults with sqlcipher:

Core was generated by `python test_blobs.py'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f091be4575d in EVP_EncryptUpdate () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
gdb$ bt
#0  0x00007f091be4575d in EVP_EncryptUpdate () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#1  0x00007f091b282e3b in ?? () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#2  0x00007f091b29347e in sqlcipher_page_cipher () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#3  0x00007f091b2a5104 in sqlite3Codec () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#4  0x00007f091b2b3799 in ?? () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#5  0x00007f091b2bb5fa in ?? () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#6  0x00007f091b2bb7cf in ?? () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#7  0x00007f091b2bf421 in ?? () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#8  0x00007f091b2ee926 in ?? () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#9  0x00007f091b2ef8cf in sqlite3_step () from /usr/lib/x86_64-linux-gnu/libsqlcipher.so.0
#10 0x00007f091b5460c0 in pysqlite_step (statement=0x56530ea208c8, connection=) at src/util.c:37
#11 0x00007f091b54444e in _pysqlite_query_execute (self=0x7f091d7d2030, multiple=, args=) at src/cursor.c:650
#12 0x000056530d2373fa in call_function (oparg=, pp_stack=0x7fffd581ede0) at ../Python/ceval.c:4352
#13 PyEval_EvalFrameEx () at ../Python/ceval.c:2989
#14 0x000056530d235525 in PyEval_EvalCodeEx () at ../Python/ceval.c:3584
#15 0x000056530d2352c9 in PyEval_EvalCode (co=, globals=, locals=) at ../Python/ceval.c:669
#16 0x000056530d264e7f in run_mod.lto_priv () at ../Python/pythonrun.c:1376
#17 0x000056530d25fe52 in PyRun_FileExFlags () at ../Python/pythonrun.c:1362
#18 0x000056530d25f99e in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:948
#19 0x000056530d210b81 in Py_Main () at ../Modules/main.c:640
#20 0x00007f091c8662b1 in __libc_start_main (main=0x56530d2104b0 , argc=0x2, argv=0x7fffd581f228, init=, fini=, rtld_fini=, stack_end=0x7fffd581f218) at ../csu/libc-start.c:291
#21 0x000056530d2103aa in _start ()

at the same time, compilation with the bundled amalgamation is broken, don't know if it's directly related:

amalgamation/sqlite3.c: In function ‘sqlcipher_openssl_hmac’:
amalgamation/sqlite3.c:18401:12: error: storage size of ‘hctx’ isn’t known
   HMAC_CTX hctx;
            ^~~~
amalgamation/sqlite3.c:18403:3: warning: implicit declaration of function ‘HMAC_CTX_init’ [-Wimplicit-function-declaration]
   HMAC_CTX_init(&hctx);
   ^~~~~~~~~~~~~
amalgamation/sqlite3.c:18408:3: warning: implicit declaration of function ‘HMAC_CTX_cleanup’ [-Wimplicit-function-declaration]
   HMAC_CTX_cleanup(&hctx);
   ^~~~~~~~~~~~~~~~
amalgamation/sqlite3.c:18401:12: warning: unused variable ‘hctx’ [-Wunused-variable]
   HMAC_CTX hctx;
            ^~~~
amalgamation/sqlite3.c: In function ‘sqlcipher_openssl_cipher’:
amalgamation/sqlite3.c:18418:18: error: storage size of ‘ectx’ isn’t known
   EVP_CIPHER_CTX ectx;
                  ^~~~

(from redmine: created on 2017-01-08)