Improve check for overly-long extensible node name.
authorRobert Haas <rhaas@postgresql.org>
Mon, 14 Mar 2016 17:48:35 +0000 (13:48 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 14 Mar 2016 17:52:52 +0000 (13:52 -0400)
The old code is bad for two reasons.  First, it has an off-by-one
error.  Second, it won't help if you aren't running with assertions
enabled.  Per discussion, we want a check here in that case too.

Author: KaiGai Kohei, adjusted by me.
Reviewed-by: Petr Jelinek
Discussion: 56E0D547.1030101@2ndquadrant.com

src/backend/nodes/extensible.c

index e78a12bab7e88e7c28a60f75e53b3901f81e3218..2473b658b175bee07294533706dd4cf59b955d7d 100644 (file)
@@ -51,7 +51,8 @@ RegisterExtensibleNodeMethods(const ExtensibleNodeMethods *methods)
                                                                                          100, &ctl, HASH_ELEM);
        }
 
-       Assert(strlen(methods->extnodename) <= EXTNODENAME_MAX_LEN);
+       if (strlen(methods->extnodename) >= EXTNODENAME_MAX_LEN)
+               elog(ERROR, "extensible node name is too long");
 
        entry = (ExtensibleNodeEntry *) hash_search(extensible_node_methods,
                                                                                                methods->extnodename,