summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2007-12-18 00:04:37 +0000
committerTom Lane2007-12-18 00:04:37 +0000
commit45cbed70da58b18f6499e9e22de7199b3fd1beec (patch)
tree0fb1de17f8f19647d5f042da2e35952943aef96f
parent886c11405674d2dde231bca690c67d7404d0e2eb (diff)
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.
-rw-r--r--src/backend/utils/adt/geo_ops.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index 547dcac2c3..dea94a6485 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -1456,7 +1456,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")));
@@ -3484,7 +3484,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")));