Gitweb:
https://git.exim.org/exim.git/commitdiff/35c22ec7c2bd08ba6631e29769a8ece18cbc76c0
Commit: 35c22ec7c2bd08ba6631e29769a8ece18cbc76c0
Parent: 56ed4f42c83f576badd797a6ec6ba81ad73166ea
Author: Jeremy Harris <jgh146exb@???>
AuthorDate: Tue Jul 23 13:26:24 2024 +0100
Committer: Jeremy Harris <jgh146exb@???>
CommitDate: Tue Jul 23 13:31:33 2024 +0100
Fix dbmjz lookup
Broken-by: c66a6edf7ba8
---
src/src/dbfn.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/src/dbfn.c b/src/src/dbfn.c
index 16b300180..1044611cc 100644
--- a/src/src/dbfn.c
+++ b/src/src/dbfn.c
@@ -376,14 +376,13 @@ DEBUG(D_hints_lookup)
* Read from database file *
*************************************************/
-/* Passing back the pointer unchanged is useless, because there is
+/* Read, using a defined-length key (permitting embedded NULs).
+
+Passing back the pointer unchanged is useless, because there is
no guarantee of alignment. Since all the records used by Exim need
to be properly aligned to pick out the timestamps, etc., we might as
well do the copying centrally here.
-Most calls don't need the length, so there is a macro called dbfn_read which
-has two arguments; it calls this function adding NULL as the third.
-
Arguments:
dbblock a pointer to an open database block
key the key of the record to be read
@@ -421,9 +420,11 @@ if (!exim_dbget(dbblock->dbptr, &key_datum, &result_datum))
store the taint status with the data. */
dlen = exim_datum_size_get(&result_datum);
-yield = store_get(dlen, GET_TAINTED);
-memcpy(yield, exim_datum_data_get(&result_datum), dlen);
DEBUG(D_hints_lookup) debug_printf_indent("dbfn_read: size %u return\n", dlen);
+
+yield = store_get(dlen+1, GET_TAINTED);
+memcpy(yield, exim_datum_data_get(&result_datum), dlen);
+((uschar *)yield)[dlen] = '\0';
if (length) *length = dlen;
exim_datum_free(&result_datum); /* Some DBM libs require freeing */
@@ -431,7 +432,11 @@ return yield;
}
-/*
+/* Read, using a NUL-terminated key.
+
+Most calls don't need the length, so there is a macro called dbfn_read which
+has two arguments; it calls this function adding NULL as the third.
+
Arguments:
dbblock a pointer to an open database block
key the key of the record to be read (NUL-terminated)
--
## subscription configuration (requires account):
##
https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at
http://www.exim.org/
## Please use the Wiki with this list -
http://wiki.exim.org/