Browse Source

Ticket 47740 - Crash caused by changes to certmap.c

Bug Description: dncomps & filtercomps could be incorrectly freed,
                 which lead to a crash.

Fix Description: Allocate "" for dncomps & filtercomps, instead of
                 setting it on the stack.

https://fedorahosted.org/389/ticket/47740

Reviewed by: rmeggins(Thanks!)
Mark Reynolds 11 years ago
parent
commit
33b98f1c90
1 changed files with 4 additions and 4 deletions
  1. 4 4
      lib/ldaputil/certmap.c

+ 4 - 4
lib/ldaputil/certmap.c

@@ -524,7 +524,7 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
     }
     else if (rv == LDAPU_SUCCESS && !dncomps) {
         certinfo->dncompsState = COMPS_EMPTY;
-        dncomps = "";		/* present but empty */
+        dncomps = strdup("");		/* present but empty */
     }
 
     rv = parse_into_bitmask (dncomps, &certinfo->dncomps, -1);
@@ -547,12 +547,12 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
     }
     else if (rv == LDAPU_SUCCESS && !filtercomps) {
         certinfo->filtercompsState = COMPS_EMPTY;
-        filtercomps = "";	/* present but empty */
+        filtercomps = strdup("");	/* present but empty */
     }
 
     rv = parse_into_bitmask (filtercomps, &certinfo->filtercomps, 0);
 
-    if (filtercomps) free(filtercomps);
+    free(filtercomps); filtercomps = NULL;
     
     if (rv != LDAPU_SUCCESS) return rv;
 
@@ -590,7 +590,7 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
     else if (rv == LDAPU_FAILED)  rv = LDAPU_SUCCESS;
 
     if (verify) free(verify);
-    
+
     if (rv != LDAPU_SUCCESS) return rv;
 
     {