From f3cca3d2e4c327ffb109539bdec4ed41e66d2648 Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Wed, 18 Feb 2009 23:54:51 +0000
Subject: [PATCH] ITS#5927

---
 CHANGES                         |  1 +
 servers/slapd/overlays/pcache.c | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/CHANGES b/CHANGES
index 6dc78b000e..a6b5e8e91d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@ OpenLDAP 2.4.15 Engineering
 	Fixed slapd corrupt contextCSN (ITS#5947)
 	Fixed slapd syncrepl order to match on add/delete (ITS#5954)
 	Fixed slapd-bdb/hdb behavior with unallocatable shm (ITS#5956)
+	Fixed slapo-pcache caching invalid entries (ITS#5927)
 	Fixed slapo-rwm objectClass preservation (ITS#5760)
 	Build Environment
 		Fixed tester library linking for windows (ITS#5740)
diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c
index 3f317cfc0c..adf98104fc 100644
--- a/servers/slapd/overlays/pcache.c
+++ b/servers/slapd/overlays/pcache.c
@@ -1993,6 +1993,19 @@ pcache_op_cleanup( Operation *op, SlapReply *rs ) {
 				goto over;
 			}
 
+			/* check for malformed entries: attrs with no values */
+			{
+				Attribute *a = e->e_attrs;
+				for (; a; a=a->a_next) {
+					if ( !a->a_numvals ) {
+						Debug( pcache_debug, "%s: query not cacheable because of attrs without values in DN \"%s\" (%s)\n",
+						op->o_log_prefix, rs->sr_entry->e_name.bv_val,
+						a->a_desc->ad_cname.bv_val );
+						goto over;
+					}
+				}
+			}
+
 			if ( si->count < si->max ) {
 				si->count++;
 				e = entry_dup( rs->sr_entry );
-- 
GitLab