From 7be39bb0be87a2fe6ea64c9d48130b78412968a8 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 4 Sep 2009 11:20:23 +0000 Subject: Tigthen binary receive functions so that they reject values that the text input functions don't accept either. While the backend can handle such values fine, they can cause trouble in clients and in pg_dump/restore. This is followup to the original issue on time datatype reported by Andrew McNamara a while ago. Like that one, none of these seem worth back-patching. --- src/backend/utils/adt/int.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/adt/int.c') diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index ad4df06572f..66cbca7079c 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.85 2009/09/03 18:48:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.86 2009/09/04 11:20:22 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -225,13 +225,21 @@ int2vectorrecv(PG_FUNCTION_ARGS) Assert(!locfcinfo.isnull); - /* sanity checks: int2vector must be 1-D, no nulls */ + /* sanity checks: int2vector must be 1-D, 0-based, no nulls */ if (ARR_NDIM(result) != 1 || ARR_HASNULL(result) || - ARR_ELEMTYPE(result) != INT2OID) + ARR_ELEMTYPE(result) != INT2OID || + ARR_LBOUND(result)[0] != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid int2vector data"))); + + /* check length for consistency with int2vectorin() */ + if (ARR_DIMS(result)[0] > FUNC_MAX_ARGS) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("oidvector has too many elements"))); + PG_RETURN_POINTER(result); } -- cgit v1.2.3