|
|
dc8c34 |
From d5c51aadcd15426608501128865c877bd5a2f50c Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Ludwig Krispenz <lkrispen@redhat.com>
|
|
|
dc8c34 |
Date: Tue, 26 Nov 2013 09:15:53 +0100
|
|
|
dc8c34 |
Subject: [PATCH 150/225] Ticket 47591 - entries with empty objectclass
|
|
|
dc8c34 |
attribute value can be hidden
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug Description: The problem is that for the empty value
|
|
|
dc8c34 |
|
|
|
dc8c34 |
objectClass;vdcsn-5283b8e0000000c80000;deleted
|
|
|
dc8c34 |
|
|
|
dc8c34 |
it is compared to "ldapsubentry" and "nstombstone"
|
|
|
dc8c34 |
|
|
|
dc8c34 |
'if (PL_strncasecmp(type.bv_val,"tombstone",0)'
|
|
|
dc8c34 |
|
|
|
dc8c34 |
and with length 0, this is always true.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix Description: add a check bv_len >= strlen(valuetocompare)
|
|
|
dc8c34 |
or bv_len == strlen(valuetocompare)
|
|
|
dc8c34 |
define constants for lengths
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47591
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by: richm, thanks
|
|
|
dc8c34 |
(cherry picked from commit 766e747e04d301a4cd48911b71d904847963940d)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/entry.c | 15 ++++++++-------
|
|
|
dc8c34 |
ldap/servers/slapd/slapi-plugin.h | 15 ++++++++++++++-
|
|
|
dc8c34 |
2 files changed, 22 insertions(+), 8 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
index a43dc21..d7df631 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
@@ -327,7 +327,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo )
|
|
|
dc8c34 |
rawdn = NULL; /* Set once in the loop.
|
|
|
dc8c34 |
This won't affect the caller's passed address. */
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- if ( PL_strncasecmp( type.bv_val, "dn", type.bv_len ) == 0 ) {
|
|
|
dc8c34 |
+ if ( type.bv_len == SLAPI_ATTR_DN_LENGTH && PL_strncasecmp( type.bv_val, SLAPI_ATTR_DN, type.bv_len ) == 0 ) {
|
|
|
dc8c34 |
if ( slapi_entry_get_dn_const(e)!=NULL ) {
|
|
|
dc8c34 |
char ebuf[ BUFSIZ ];
|
|
|
dc8c34 |
LDAPDebug( LDAP_DEBUG_TRACE,
|
|
|
dc8c34 |
@@ -363,7 +363,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo )
|
|
|
dc8c34 |
continue;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- if ( PL_strncasecmp( type.bv_val, "rdn", type.bv_len ) == 0 ) {
|
|
|
dc8c34 |
+ if ( type.bv_len == SLAPI_ATTR_RDN_LENGTH && PL_strncasecmp( type.bv_val, SLAPI_ATTR_RDN, type.bv_len ) == 0 ) {
|
|
|
dc8c34 |
if ( NULL == slapi_entry_get_rdn_const( e )) {
|
|
|
dc8c34 |
slapi_entry_set_rdn( e, value.bv_val );
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -374,13 +374,13 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo )
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* If SLAPI_STR2ENTRY_NO_ENTRYDN is set, skip entrydn */
|
|
|
dc8c34 |
if ( (flags & SLAPI_STR2ENTRY_NO_ENTRYDN) &&
|
|
|
dc8c34 |
- PL_strncasecmp( type.bv_val, "entrydn", type.bv_len ) == 0 ) {
|
|
|
dc8c34 |
+ type.bv_len == SLAPI_ATTR_ENTRYDN_LENGTH && PL_strncasecmp( type.bv_val, SLAPI_ATTR_ENTRYDN, type.bv_len ) == 0 ) {
|
|
|
dc8c34 |
if (freeval) slapi_ch_free_string(&value.bv_val);
|
|
|
dc8c34 |
continue;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* retrieve uniqueid */
|
|
|
dc8c34 |
- if ( PL_strncasecmp (type.bv_val, SLAPI_ATTR_UNIQUEID, type.bv_len) == 0 ){
|
|
|
dc8c34 |
+ if ( type.bv_len == SLAPI_ATTR_UNIQUEID_LENGTH && PL_strncasecmp (type.bv_val, SLAPI_ATTR_UNIQUEID, type.bv_len) == 0 ){
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if (e->e_uniqueid != NULL){
|
|
|
dc8c34 |
LDAPDebug (LDAP_DEBUG_TRACE,
|
|
|
dc8c34 |
@@ -398,10 +398,11 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo )
|
|
|
dc8c34 |
continue;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- if (PL_strncasecmp(type.bv_val,"objectclass",type.bv_len) == 0) {
|
|
|
dc8c34 |
- if (PL_strncasecmp(value.bv_val,"ldapsubentry",value.bv_len) == 0)
|
|
|
dc8c34 |
+ if (value_state == VALUE_PRESENT && type.bv_len >= SLAPI_ATTR_OBJECTCLASS_LENGTH
|
|
|
dc8c34 |
+ && PL_strncasecmp(type.bv_val, SLAPI_ATTR_OBJECTCLASS, type.bv_len) == 0) {
|
|
|
dc8c34 |
+ if (value.bv_len >= SLAPI_ATTR_VALUE_SUBENTRY_LENGTH && PL_strncasecmp(value.bv_val,SLAPI_ATTR_VALUE_SUBENTRY,value.bv_len) == 0)
|
|
|
dc8c34 |
e->e_flags |= SLAPI_ENTRY_LDAPSUBENTRY;
|
|
|
dc8c34 |
- if (PL_strncasecmp(value.bv_val, SLAPI_ATTR_VALUE_TOMBSTONE,value.bv_len) == 0)
|
|
|
dc8c34 |
+ if (value.bv_len >= SLAPI_ATTR_VALUE_TOMBSTONE_LENGTH && PL_strncasecmp(value.bv_val, SLAPI_ATTR_VALUE_TOMBSTONE,value.bv_len) == 0)
|
|
|
dc8c34 |
e->e_flags |= SLAPI_ENTRY_FLAG_TOMBSTONE;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
index 642f515..eeac43e 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
@@ -392,9 +392,22 @@ NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
|
|
|
dc8c34 |
#define SLAPI_ATTR_OBJECTCLASS "objectclass"
|
|
|
dc8c34 |
#define SLAPI_ATTR_VALUE_TOMBSTONE "nsTombstone"
|
|
|
dc8c34 |
#define SLAPI_ATTR_VALUE_PARENT_UNIQUEID "nsParentUniqueID"
|
|
|
dc8c34 |
+#define SLAPI_ATTR_VALUE_SUBENTRY "ldapsubentry"
|
|
|
dc8c34 |
#define SLAPI_ATTR_NSCP_ENTRYDN "nscpEntryDN"
|
|
|
dc8c34 |
#define SLAPI_ATTR_ENTRYUSN "entryusn"
|
|
|
dc8c34 |
-#define SLAPI_ATTR_ENTRYDN "entrydn"
|
|
|
dc8c34 |
+#define SLAPI_ATTR_ENTRYDN "entrydn"
|
|
|
dc8c34 |
+#define SLAPI_ATTR_DN "dn"
|
|
|
dc8c34 |
+#define SLAPI_ATTR_RDN "rdn"
|
|
|
dc8c34 |
+#define SLAPI_ATTR_UNIQUEID_LENGTH 10
|
|
|
dc8c34 |
+#define SLAPI_ATTR_OBJECTCLASS_LENGTH 11
|
|
|
dc8c34 |
+#define SLAPI_ATTR_VALUE_TOMBSTONE_LENGTH 11
|
|
|
dc8c34 |
+#define SLAPI_ATTR_VALUE_PARENT_UNIQUEID_LENGTH 16
|
|
|
dc8c34 |
+#define SLAPI_ATTR_VALUE_SUBENTRY_LENGTH 12
|
|
|
dc8c34 |
+#define SLAPI_ATTR_NSCP_ENTRYDN_LENGTH 11
|
|
|
dc8c34 |
+#define SLAPI_ATTR_ENTRYUSN_LENGTH 8
|
|
|
dc8c34 |
+#define SLAPI_ATTR_ENTRYDN_LENGTH 7
|
|
|
dc8c34 |
+#define SLAPI_ATTR_DN_LENGTH 2
|
|
|
dc8c34 |
+#define SLAPI_ATTR_RDN_LENGTH 3
|
|
|
dc8c34 |
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* opaque structures */
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|