aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-12-18 00:04:37 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-12-18 00:04:37 +0000
commit11b709714cd85adbea4000c0819d0fc7a726a0bb (patch)
tree7779469c34d0f29877189c6996394bcc360d550d /src
parent86f6837ac3be9db0992dba53ad0af4b66ef21bef (diff)
downloadpostgresql-11b709714cd85adbea4000c0819d0fc7a726a0bb.tar.gz
postgresql-11b709714cd85adbea4000c0819d0fc7a726a0bb.zip
Make path_recv() and poly_recv() reject paths/polygons containing no points.
The zero-point case is sensible so far as the data structure is concerned, so maybe we ought to allow it sometime; but right now the textual input routines for these types don't allow it, and it seems that not all the functions for the types are prepared to cope. Report and patch by Merlin Moncure.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/geo_ops.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index 19de68af870..4b596446649 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.82.2.1 2004/05/12 22:39:00 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.82.2.2 2007/12/18 00:04:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1383,7 +1383,7 @@ path_recv(PG_FUNCTION_ARGS)
closed = pq_getmsgbyte(buf);
npts = pq_getmsgint(buf, sizeof(int32));
- if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point)))
+ if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid number of points in external \"path\" value")));
@@ -3412,7 +3412,7 @@ poly_recv(PG_FUNCTION_ARGS)
int size;
npts = pq_getmsgint(buf, sizeof(int32));
- if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point)))
+ if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid number of points in external \"polygon\" value")));