1
0
Эх сурвалжийг харах

Bug 658312 - Invalid free in Managed Entry plug-in

The previous patch for bug 658312 would perform an invalid free
with a mapping rule used the $dn macro.  We get the DN of the
origin entry with slapi_entry_get_ndn().  The returned value is
not supposed to be freed.  This patch adds a flag to indicate it
we need to perform a free of the mapping value or not.
Nathan Kinder 15 жил өмнө
parent
commit
6d7ddbb4c2

+ 5 - 1
ldap/servers/plugins/mep/mep.c

@@ -1436,19 +1436,23 @@ mep_parse_mapped_attr(char *mapping, Slapi_Entry *origin,
     if (map_type) {
         if (origin) {
             char *map_val = NULL;
+            int freeit = 0;
 
             /* If the map type is dn, fetch the origin dn. */
             if (slapi_attr_type_cmp(map_type, "dn", SLAPI_TYPE_CMP_EXACT) == 0) {
                 map_val = slapi_entry_get_ndn(origin);
             } else {
                 map_val = slapi_entry_attr_get_charptr(origin, map_type);
+                freeit = 1;
             }
 
             if (map_val) {
                 /* Create the new mapped value. */
                 *value = slapi_ch_smprintf("%s%s%s", pre_str,
                                            map_val, post_str);
-                slapi_ch_free_string(&map_val);
+                if (freeit) {
+                    slapi_ch_free_string(&map_val);
+                }
             } else {
                 slapi_log_error( SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
                     "mep_parse_mapped_attr: Mapped attribute \"%s\" "