From: <svn...@op...> - 2009-04-02 19:20:20
|
Author: scriptor Date: Thu Apr 2 21:20:05 2009 New Revision: 5518 URL: http://www.opensync.org/changeset/5518 Log: ldap_format_avoid_duplicate_attribute() should not be called if its first argument is NULL, because it is useless. Modified: plugins/ldap-sync/src/ldap_format.c Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Thu Apr 2 21:19:57 2009 (r5517) +++ plugins/ldap-sync/src/ldap_format.c Thu Apr 2 21:20:05 2009 (r5518) @@ -372,7 +372,7 @@ unsigned int i = 0; - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ldapmods, name); + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, ldapmods, name); if (ldapmods == NULL) { @@ -457,9 +457,11 @@ - if (ldap_format_avoid_duplicate_attribute(list, (const char *)ldapattr) == 2) { - osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: Suppressing LDAP attribute \"%s\", because it is already present.", __FILE__, __LINE__, ldapattr); - goto out; + if (list) { + if (ldap_format_avoid_duplicate_attribute(list, (const char *)ldapattr) == 2) { + osync_trace(TRACE_INTERNAL, "%s:%i: WARNING: Suppressing LDAP attribute \"%s\", because it is already present.", __FILE__, __LINE__, ldapattr); + goto out; + } } @@ -4103,19 +4105,20 @@ // This apparently conflicts with the "unbounded" specification in // many of the libopensync XML schemata. I have not implemented // any solution to this problem, yet. - if (ldap_format_avoid_duplicate_attribute(*ldapmods, (const char *)name) == 2) { - osync_trace(TRACE_ERROR, "%s:%i: WARNING: Suppressing LDAP attribute \"%s\", because it is already present.", __FILE__, __LINE__, name); + if (*ldapmods) { + if (ldap_format_avoid_duplicate_attribute(*ldapmods, (const char *)name) == 2) { + osync_trace(TRACE_ERROR, "%s:%i: WARNING: Suppressing LDAP attribute \"%s\", because it is already present.", __FILE__, __LINE__, name); - if (value) { - xmlFree(value); - value = NULL; - } + if (value) { + xmlFree(value); + value = NULL; + } - continue; + continue; + } } - // Add this name-value-pair to the list of LDAP mods. // "mods" are the lines in an LDIF file; the various LDAP attributes. *ldapmods = ldap_format_append_ldapmod(*ldapmods, (gchar *)name, (gchar *)value); |