[Fedora-directory-commits] ldapserver/ldap/servers/plugins/dna dna.c, 1.16, 1.17

Nathan Kinder nkinder at fedoraproject.org
Thu Feb 26 21:41:18 UTC 2009


Author: nkinder

Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/dna
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv9289/ldap/servers/plugins/dna

Modified Files:
	dna.c 
Log Message:
Resolves: bug 487574
Bug Description: A crash occurs in the DNA plug-in when you delete an existing
 value of a managed attribute.
Reviewed by: rmeggins (thanks!)
Files: see diff
Branch: HEAD
Fix Description: The DNA code was always expecting a value to be present when
 processing a modify operation.  The delete and replace modify operations can
 be issues with no values.  These operations were an oversight in the DNA code.

 The fix adds cases to handle delete and replace modify operations.  For a replace,
 we check if we are replacing all values with nothing, and generate a new value from
 the range.  If we're processing a delete with no values specified, we also generate
 a new value.  If the delete has values specified, we check to see if the operation
 leaves any values in the existing entry.  If no existing values would remain after
 the operation, we generate a new value.
Platforms tested: F9
Flag Day: no
Doc impact: no



Index: dna.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/dna/dna.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- dna.c	5 Dec 2008 22:41:50 -0000	1.16
+++ dna.c	26 Feb 2009 21:41:15 -0000	1.17
@@ -2628,18 +2628,44 @@
 
                     if (slapi_attr_types_equivalent(type,
                                                     config_entry->type)) {
-                        struct berval *bv =
-                            slapi_mod_get_first_value(smod);
-                        int len = strlen(config_entry->generate);
-
-
-                        if (len == bv->bv_len) {
-                            if (!slapi_UTF8NCASECMP(bv->bv_val,
-                                                    config_entry->generate,
-                                                    len))
+                        /* If all values are being deleted, we need to
+                         * generate a new value. */
+                        if (SLAPI_IS_MOD_DELETE(slapi_mod_get_operation(smod))) {
+                            int numvals = slapi_mod_get_num_values(smod);
 
+                            if (numvals == 0) {
+                                generate = 1;
+                            } else {
+                                Slapi_Attr *attr = NULL;
+                                int e_numvals = 0;
+
+                                slapi_entry_attr_find(e, type, &attr);
+                                if (attr) {
+                                    slapi_attr_get_numvalues(attr, &e_numvals);
+                                    if (numvals >= e_numvals) {
+                                        generate = 1;
+                                    }
+                                }
+                            }
+                        } else {
+                            /* This is either adding or replacing a value */
+                            struct berval *bv = slapi_mod_get_first_value(smod);
+
+                            /* If we have a value, see if it's the magic value. */
+                            if (bv) {
+                                int len = strlen(config_entry->generate);
+                                if (len == bv->bv_len) {
+                                    if (!slapi_UTF8NCASECMP(bv->bv_val,
+                                                            config_entry->generate,
+                                                            len))
+                                        generate = 1;
+                                    break;
+                                }
+                            } else {
+                                /* This is a replace with no new values, so we need
+                                 * to generate a new value. */
                                 generate = 1;
-                            break;
+                            }
                         }
                     }
 




More information about the Fedora-directory-commits mailing list