Fix ldap lookups for zero-length attribute value. Bug 2251
authorJeremy Harris <jgh146exb@wizmail.org>
Sun, 11 Mar 2018 18:46:23 +0000 (18:46 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Sun, 11 Mar 2018 18:53:22 +0000 (18:53 +0000)
Broken-by: acec9514b1
doc/doc-txt/ChangeLog
src/src/lookups/ldap.c

index 06ed2eeb5a4900bbe5d90da54b2bbe91117f45e1..e4ad9f0c546d7f78310ee7a993537aec976892cd 100644 (file)
@@ -135,6 +135,9 @@ JH/26 Bug 2253: For logging delivery lines under PRDR, append the overall
       the "C=" log element.  It can have useful tracking info from the
       destination system.  Patch from Simon Arlott.
 
+JH/27 Bug 2251: Fix ldap lookups that return a single attribute having zero-
+      length value.  Previously this would segfault.
+
 
 Exim version 4.90
 -----------------
index 2ebe734cd2c074c312bc38c1da2238992cd504d0..63c0edf7979460c90a6738a962ad2572c78f5a9e 100644 (file)
@@ -840,13 +840,13 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr, &result)) ==
   result = NULL;
   }            /* End "while" loop for multiple results */
 
-/* Terminate the dynamic string that we have built and reclaim unused store */
+/* Terminate the dynamic string that we have built and reclaim unused store.
+In the odd case of a single attribute with zero-length value, allocate
+an empty string. */
 
-if (data)
-  {
-  (void) string_from_gstring(data);
-  gstring_reset_unused(data);
-  }
+if (!data) data = string_get(1);
+(void) string_from_gstring(data);
+gstring_reset_unused(data);
 
 /* Copy the last dn into eldap_dn */