From: Jeremy Harris Date: Fri, 7 Jun 2024 19:12:27 +0000 (+0100) Subject: sqlite hintsdb: safer create of table X-Git-Tag: exim-4.98-RC1~10 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/50589c35f57a4b9465ad7041db7d5cd67c52d72b?ds=sidebyside sqlite hintsdb: safer create of table --- diff --git a/src/src/dbfn.c b/src/src/dbfn.c index 6b2027aa9..5f30ccf58 100644 --- a/src/src/dbfn.c +++ b/src/src/dbfn.c @@ -67,6 +67,8 @@ Arguments: name The single-component name of one of Exim's database files. flags Either O_RDONLY or O_RDWR, indicating the type of open required; O_RDWR implies "create if necessary" +XXX this is a mess. hintsdb.h has grown lots of code expecting O_CREAT +XXX with the obvious semantics, and not that described above. dbblock Points to an open_db block to be filled in. lof If TRUE, write to the log for actual open failures (locking failures are always logged). diff --git a/src/src/hintsdb.h b/src/src/hintsdb.h index 545c83dbd..17b5c243c 100644 --- a/src/src/hintsdb.h +++ b/src/src/hintsdb.h @@ -87,7 +87,8 @@ if ((ret = sqlite3_open_v2(CCS name, &dbp, sflags, NULL)) == SQLITE_OK) sqlite3_busy_timeout(dbp, 5000); if (flags & O_CREAT) ret == sqlite3_exec(dbp, - "CREATE TABLE tbl (ky TEXT PRIMARY KEY, dat BLOB);", NULL, NULL, NULL); + "CREATE TABLE IF NOT EXISTS tbl (ky TEXT PRIMARY KEY, dat BLOB);", + NULL, NULL, NULL); } //else // fprintf(stderr, "sqlite3_open_v2: %s\n", sqlite3_errmsg(dbp));