Ethereal-dev: [Ethereal-dev] packet-ldap.c patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Toshiyuki Maezawa <toshiyuki.maezawa@xxxxxxxxxxxxxxx>
Date: Wed, 15 Jun 2005 15:08:17 +0900 (JST)
Hi,
I noticed a bug of decoding SubstringFilter in packet-ldap.c.

I requested and captured below using ldapsearch,

% ldapsearch '(cn=a*)'
% ldapsearch '(cn=*b)'

Ethereal 0.10.11 shows '(cn=a)', '(cn=b)'.

This bug seems to be fixed by a patch below.


Thanks.

---
Toshiyuki Maezawa


--- packet-ldap.c.orig	2005-05-03 06:28:47.000000000 +0900
+++ packet-ldap.c	2005-06-15 14:46:18.915563000 +0900
@@ -753,14 +753,16 @@
     if ((tag == 1) && (string_length != 0))
       any_valued = 1;
 
-    if ( (tag == 1) || ((tag == 2) && any_valued) )
+    if ( (tag == 1) || (tag == 2) )
       (*filter_length)++;
     *filter_length += string_length;
     *filter = g_realloc(*filter, *filter_length);
 
     filterp = *filter + strlen(*filter);
-    if ( (tag == 1) || ((tag == 2) && any_valued) )
+    if ( (tag == 1) || (tag == 2) )
       *filterp++ = '*';
+	if (tag == 0)
+	  any_valued = 1;
     if (tag == 2)
       any_valued = 0;
     if (string_length != 0) {