[PATCH] Fix harmless access to uninitialized memory in ri_triggers.c.

Started by Nonameover 11 years ago2 messages
#1Noname
andres@2ndquadrant.com

From: Andres Freund <andres@anarazel.de>

When cache invalidations arrive while ri_LoadConstraintInfo() is busy
filling a new cache entry, InvalidateConstraintCacheCallBack()
compares the - not yet initialized - oidHashValue field with the
to-be-invalidated hash value. To fix check whether the entry is
already marked as invalid.
---
src/backend/utils/adt/ri_triggers.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index d30847b..e4d7b2c 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -2934,7 +2934,8 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
 	hash_seq_init(&status, ri_constraint_cache);
 	while ((hentry = (RI_ConstraintInfo *) hash_seq_search(&status)) != NULL)
 	{
-		if (hashvalue == 0 || hentry->oidHashValue == hashvalue)
+		if (hentry->valid &&
+			(hashvalue == 0 || hentry->oidHashValue == hashvalue))
 			hentry->valid = false;
 	}
 }
-- 
1.8.5.rc2.dirty

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Heikki Linnakangas
hlinnakangas@vmware.com
In reply to: Noname (#1)
Re: [PATCH] Fix harmless access to uninitialized memory in ri_triggers.c.

On 05/08/2014 07:33 PM, andres@2ndquadrant.com wrote:

When cache invalidations arrive while ri_LoadConstraintInfo() is busy
filling a new cache entry, InvalidateConstraintCacheCallBack()
compares the - not yet initialized - oidHashValue field with the
to-be-invalidated hash value. To fix check whether the entry is
already marked as invalid.

Thanks, applied.

- Heikki

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers