浏览代码

Ticket #545 - Segfault during initial LDIF import: str2entry_dupcheck()

Bug description: If an attribute type having multiple values exists
in an entry, and any compare function is not associated with the
attribute type, fast_dup_check flag was not disabled from the second
time.  Since fast_dup_check requires the compare function based on
the attribute syntax, it causes the segfault.

Fix description: This patch checks whether a compare function is
associated with the multi-valued attribute not just at the first
time the attribute type appears but at the second time and after,
and disable fast_dup_check properly if needed.

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

Reviewed by Rich (Thank you!!)
Noriko Hosoi 13 年之前
父节点
当前提交
8bea55468d
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 13 2
      ldap/servers/slapd/entry.c

+ 13 - 2
ldap/servers/slapd/entry.c

@@ -803,8 +803,8 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
 		bvtype = bv_null;
 		bvvalue = bv_null;
 		if ( slapi_ldif_parse_line( s, &bvtype, &bvvalue, &freeval ) < 0 ) {
-		    LDAPDebug( LDAP_DEBUG_TRACE,
-			    "<= str2entry_dupcheck NULL (parse_line)\n", 0, 0, 0 );
+		    LDAPDebug1Arg(LDAP_DEBUG_ANY,
+		                  "Warning: ignoring invalid line \"%s\"...\n", s);
 		    continue;
 		}
 		type = bvtype.bv_val;
@@ -1047,6 +1047,17 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
 			}
 			prev_attr = &attrs[nattrs];
 			nattrs++;
+		} else { /* prev_attr != NULL */
+			if ( check_for_duplicate_values ) {
+				/*
+				 * If the compare function wasn't available,
+				 * we have to revert to AVL-tree-based dup checking,
+				 * which uses index keys for comparisons
+				 */
+				if (NULL == prev_attr->sa_comparefn) {
+					fast_dup_check = 0;
+				}
+			}
 		}
 
 		sa = prev_attr;	/* For readability */