1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-08 00:47:37 +03:00

Check length of enum literals on definition and input to make sure they will fit in a name field and not cause syscache errors.

This commit is contained in:
Andrew Dunstan
2007-04-02 22:14:17 +00:00
parent ffb27446cc
commit 325feaef7f
2 changed files with 24 additions and 2 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.1 2007/04/02 03:49:39 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/enum.c,v 1.2 2007/04/02 22:14:17 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,6 +45,15 @@ cstring_enum(char *name, Oid enumtypoid)
HeapTuple tup;
Oid enumoid;
/* must check length to prevent Assert failure within SearchSysCache */
if (strlen(name) >= NAMEDATALEN)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input value for enum %s: \"%s\"",
format_type_be(enumtypoid),
name)));
tup = SearchSysCache(ENUMTYPOIDNAME,
ObjectIdGetDatum(enumtypoid),
CStringGetDatum(name),