From 225c84f0f35d3aea1f0845eedde7632c371e1f99 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 5 May 2022 16:22:54 +0100 Subject: [PATCH 1/1] Fix dbmjz lookup. Bug 2884 Broken-by: 0cc804c877 --- src/src/lookups/dbmdb.c | 6 ++++-- test/aux-fixed/2301.testsasldb | Bin 0 -> 12288 bytes test/confs/2301 | 4 ++++ test/scripts/2300-DBM/2301 | 5 +++++ test/stdout/2301 | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/aux-fixed/2301.testsasldb create mode 100644 test/confs/2301 create mode 100644 test/scripts/2300-DBM/2301 create mode 100644 test/stdout/2301 diff --git a/src/src/lookups/dbmdb.c b/src/src/lookups/dbmdb.c index edc49e581..32514afcc 100644 --- a/src/src/lookups/dbmdb.c +++ b/src/src/lookups/dbmdb.c @@ -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 index 0000000000000000000000000000000000000000..50a05965d2a4673b9dff3928863a2f48f24fc4e4 GIT binary patch literal 12288 zcmeI%F$%&k6oBE^4pPC=E-r#s=;B2@fe>iHLem|H`o11s=3Oacj!Mqj+GdZcl z{~#}~FC~y~3lS0V?9eddfef{X?Fh6G@%!m52hnUI50UfqbUBXtCEeq-k9M@a9hM8X zuWJMX2q1s}0tg_000IagfB*srd|$x5qx*7=B)ms969^!H00IagfB*srAb z0$!8VP1$x+o{D}Y+1{+mB1`i1&J?z}t+Q%w>bl)jsUAV^|IRyqEMb2*r{6U{dH>fR cdH?SX$p|2T00IagfB*srAbe>$36k3)Z~y=R literal 0 HcmV?d00001 diff --git a/test/confs/2301 b/test/confs/2301 new file mode 100644 index 000000000..3e88df718 --- /dev/null +++ b/test/confs/2301 @@ -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 index 000000000..9ba0c5079 --- /dev/null +++ b/test/scripts/2300-DBM/2301 @@ -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 index 000000000..ca59bf00b --- /dev/null +++ b/test/stdout/2301 @@ -0,0 +1,2 @@ +> testpw +> -- 2.30.2