res->len = sqlite3_column_bytes(statement, 0);
# ifdef COMPILE_UTILITY
-res->data = malloc(res->len);
+if (!(res->data = malloc(res->len +1)))
+ { sqlite3_finalize(statement); return FALSE; }
# else
-res->data = store_get(res->len, GET_TAINTED);
+res->data = store_get(res->len +1, GET_TAINTED);
# endif
memcpy(res->data, sqlite3_column_blob(statement, 0), res->len);
res->data[res->len] = '\0';
# ifdef COMPILE_UTILITY
/* fprintf(stderr, "exim_dbget(k len %d '%.*s')\n", (int)key->len, (int)key->len, key->data); */
-qry = malloc(i = snprintf(NULL, 0, FMT, (int) key->len, key->data));
+i = snprintf(NULL, 0, FMT, (int) key->len, key->data)+1;
+if (!(qry = malloc(i)))
+ return FALSE;
snprintf(CS qry, i, FMT, (int) key->len, key->data);
ret = exim_dbget__(dbp, qry, res);
free(qry);
{
int hlen = data->len * 2, off = 0, res;
# define FMT "INSERT OR %s INTO tbl (ky,dat) VALUES ('%.*s', X'%.*s');"
+uschar * qry;
# ifdef COMPILE_UTILITY
uschar * hex = malloc(hlen+1);
+if (!hex) return EXIM_DBPUTB_DUP; /* best we can do */
# else
uschar * hex = store_get(hlen+1, data->data);
# endif
-uschar * qry;
for (const uschar * s = data->data, * t = s + data->len; s < t; s++, off += 2)
sprintf(CS hex + off, "%02X", *s);
# ifdef COMPILE_UTILITY
-res = snprintf(CS hex, 0, FMT, alt, (int) key->len, key->data, hlen, hex);
-qry = malloc(res);
+res = snprintf(CS hex, 0, FMT, alt, (int) key->len, key->data, hlen, hex) +1;
+if (!(qry = malloc(res))) return EXIM_DBPUTB_DUP;
snprintf(CS qry, res, FMT, alt, (int) key->len, key->data, hlen, hex);
/* fprintf(stderr, "exim_s_dbp(%s)\n", qry); */
res = sqlite3_exec(dbp, CS qry, NULL, NULL, NULL);
int res;
# ifdef COMPILE_UTILITY
-res = snprintf(NULL, 0, FMT, (int) key->len, key->data); /* res excludes nul */
-qry = malloc(res);
+res = snprintf(NULL, 0, FMT, (int) key->len, key->data) +1; /* res includes nul */
+if (!(qry = malloc(res))) return SQLITE_NOMEM;
snprintf(CS qry, res, FMT, (int) key->len, key->data);
res = sqlite3_exec(dbp, CS qry, NULL, NULL, NULL);
free(qry);
{
# ifdef COMPILE_UTILITY
EXIM_CURSOR * c = malloc(sizeof(int));
+if (!c) return NULL;
# else
EXIM_CURSOR * c = store_malloc(sizeof(int));
# endif
BOOL ret;
# ifdef COMPILE_UTILITY
-if (!(qry = malloc((i = snprintf(NULL, 0, FMT, *cursor))+1))) return FALSE;
+i = snprintf(NULL, 0, FMT, *cursor)+1;
+if (!(qry = malloc(i))) return FALSE;
snprintf(CS qry, i, FMT, *cursor);
/* fprintf(stderr, "exim_dbscan(%s)\n", qry); */
ret = exim_dbget__(dbp, qry, key);
# This message sometimes has a different number of seconds
s/forced fail after \d seconds/forced fail after d seconds/;
- # This message may contain a different DBM library name
- s/Failed to open \S+( \([^\)]+\))? file/Failed to open DBM file/;
-
# The message for a non-listening FIFO varies
s/:[^:]+: while opening named pipe/: Error: while opening named pipe/;
s/^(Connection request from) \[.*:.*:.*\]$/$1 \[ipv6\]/;
# Hints DB use of lockfiles is provider-dependent
- s/Failed to open \K(?:DBM|database lock) file (.*\/spool\/db\/[^.]*)(?:.lockfile)?(?=(?: for reading)?: No such file or directory$)/hintsdb $1/;
+ s/Failed to open \K(?:hintsdb|database lock) file (.*\/spool\/db\/[^.]*)(?:.lockfile)?(?=(?: for reading)?: No such file or directory$)/hintsdb $1/;
# openssl version variances
# Error lines on stdout from SSL contain process id values and file names.
###################
# The "dbmbuild" command runs exim_dbmbuild. This is used both to test the
-# utility and to make DBM files for testing DBM lookups.
+# utility and to make hintsdb files for testing hintsdb lookups.
if (/^dbmbuild\s+(\S+)\s+(\S+)/)
{
# The "dump" command runs exim_dumpdb. On different systems, the output for
# some types of dump may appear in a different order because it's just hauled
-# out of the DBM file. We can solve this by sorting. Ignore the leading
+# out of the hintsdb file. We can solve this by sorting. Ignore the leading
# date/time, as it will be flattened later during munging.
if (/^dump\s+(\S+)/)