Fix dbmjz lookup. Bug 2884
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 5 May 2022 15:22:54 +0000 (16:22 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Fri, 6 May 2022 11:47:03 +0000 (12:47 +0100)
Broken-by: 0cc804c877
src/src/lookups/dbmdb.c
test/aux-fixed/2301.testsasldb [new file with mode: 0644]
test/confs/2301 [new file with mode: 0644]
test/scripts/2300-DBM/2301 [new file with mode: 0644]
test/stdout/2301 [new file with mode: 0644]

index edc49e581dd61a9ba7676a25a9838fd4ab0f4b3f..32514afcc3ef0719fa1e56730a45c563473f6f65 100644 (file)
@@ -94,8 +94,10 @@ EXIM_DATUM key, data;
 
 exim_datum_init(&key);               /* Some DBM libraries require datums to */
 exim_datum_init(&data);              /* be cleared before use. */
-exim_datum_data_set(&key, string_copyn(keystring, length));
-exim_datum_size_set(&key, length + 1);
+length++;
+exim_datum_data_set(&key,
+  memcpy(store_get(length, keystring), keystring, length)); /* key can have embedded NUL */
+exim_datum_size_set(&key, length);
 
 if (exim_dbget(d, &key, &data))
   {
diff --git a/test/aux-fixed/2301.testsasldb b/test/aux-fixed/2301.testsasldb
new file mode 100644 (file)
index 0000000..50a0596
Binary files /dev/null and b/test/aux-fixed/2301.testsasldb differ
diff --git a/test/confs/2301 b/test/confs/2301
new file mode 100644 (file)
index 0000000..3e88df7
--- /dev/null
@@ -0,0 +1,4 @@
+# Exim test configuration 2301
+.include DIR/aux-var/std_conf_prefix
+primary_hostname = myhost.test.ex
+# End
diff --git a/test/scripts/2300-DBM/2301 b/test/scripts/2300-DBM/2301
new file mode 100644 (file)
index 0000000..9ba0c50
--- /dev/null
@@ -0,0 +1,5 @@
+# lookup dbmjz
+#
+exim -be
+${lookup{testid:test.example.invalid:userPassword}dbmjz{DIR/aux-fixed/TESTNUM.testsasldb}{$value}fail}
+****
diff --git a/test/stdout/2301 b/test/stdout/2301
new file mode 100644 (file)
index 0000000..ca59bf0
--- /dev/null
@@ -0,0 +1,2 @@
+> testpw
+>