Skip to content

Commit dbc632e

Browse files
committed
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.
1 parent cc04aaf commit dbc632e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/adt/geo_ops.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.97 2007/11/15 21:14:39 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.98 2007/12/18 00:04:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1456,7 +1456,7 @@ path_recv(PG_FUNCTION_ARGS)
14561456

14571457
closed = pq_getmsgbyte(buf);
14581458
npts = pq_getmsgint(buf, sizeof(int32));
1459-
if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point)))
1459+
if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point)))
14601460
ereport(ERROR,
14611461
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
14621462
errmsg("invalid number of points in external \"path\" value")));
@@ -3484,7 +3484,7 @@ poly_recv(PG_FUNCTION_ARGS)
34843484
int size;
34853485

34863486
npts = pq_getmsgint(buf, sizeof(int32));
3487-
if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point)))
3487+
if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point)))
34883488
ereport(ERROR,
34893489
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
34903490
errmsg("invalid number of points in external \"polygon\" value")));

0 commit comments

Comments
 (0)