SQLitePCL.raw icon indicating copy to clipboard operation
SQLitePCL.raw copied to clipboard

AccessViolationException using sqlcipher

Open ptsoccer opened this issue 8 years ago • 1 comments

If the sqlcipher key is set > 1 times (even if the key is the same) on the same connection, the next SQL statement that gets executed will give an AccessViolationException.

To recreate:

  1. Create a console project and add a nuget reference to SQLitePCLRaw.bundle_sqlcipher
  2. Replace the code in the code file with
using System.IO;
using SQLitePCL;

namespace SQLiteRawPCLSqlCipherCrash
{
	class Program
	{
		static void Main()
		{
			if (File.Exists("Test.sqlite"))
				File.Delete("Test.sqlite");

			Batteries_V2.Init();
			sqlite3 db;
			raw.sqlite3_open("Test.sqlite", out db);

			string error;
			raw.sqlite3_exec(db, "PRAGMA key = 'password'", out error);
			raw.sqlite3_exec(db, "PRAGMA key = 'password'", out error);

			raw.sqlite3_exec(db, "CREATE TABLE Test (T int)", out error);
		}
	}
}

This should crash once the create table statement runs

ptsoccer avatar Dec 18 '17 20:12 ptsoccer

I have reproduced this.

What I don't know yet is whether this behavior is specific to SQLitePCL.raw, or if the same thing happens when using sqlcipher from, say, C.

ericsink avatar Dec 18 '17 22:12 ericsink

Closing old/stale issue.

ericsink avatar Sep 22 '22 19:09 ericsink