[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

found and fixed allocation problem in SRL_ldap.c




  Hi folks,

  Just thought I'd pass on what I'm pretty sure is bug-fix for CML 2.1.

  There's a problem in SRL_ldap.c, that if a URL is passed that does not
  have a filter, the pointer within the internal structure is directed to a
  "const static" char string, which causes a fatal memory error when that
  structure is deallocated.  The solution is just to strdup a copy of the
  static string so it can be correctly deallocated later.

  Standard form patch file follows.
  Best regards,

    - Ken Stillson

--
      |   Ken Stillson             |    stillson@xxxxxxxxxxxx    |
      |   Sr. Principal Engineer   |    voice: (703) 610-2965    |
      |   Mitretek Systems         |      fax: (703) 610-2399    |


--- SRL_ldap.c.orig	2002-07-15 12:45:18.000000000 -0400
+++ SRL_ldap.c	2002-10-08 16:58:30.000000000 -0400
@@ -2642,7 +2642,7 @@

 	// Load in the standard defaults per RFC2255
 	pDesc->scope = LDAP_SCOPE_BASE;
-	pDesc->filter = (uchar *)"(objectClass=*)";
+	//__mts; cannot use const alloc; will cause free error later; see strdup solution below.  pDesc->filter = (uchar *)"(objectClass=*)";

 	// Get the DN
 	dn = strchr(purl, '/');
@@ -2706,6 +2706,9 @@
                      SRLi_hex_unescape((char *)pDesc->filter);
 				 }
 			} // Endif filter
+			else { //__mts: if not specific filter found, use default
+				pDesc->filter = (uchar *)strdup("(objectClass=*)");
+			}

 			// Load in the Scope level based on the ascii
 			if (SRLi_memicmp( scope, "one", strlen("one") ) == 0)