mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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.
This commit is contained in:
parent
5aa57951db
commit
6412f0a2fe
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.93 2006/06/26 12:32:42 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.93.2.1 2007/12/18 00:04:16 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1456,7 +1456,7 @@ path_recv(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
closed = pq_getmsgbyte(buf);
|
closed = pq_getmsgbyte(buf);
|
||||||
npts = pq_getmsgint(buf, sizeof(int32));
|
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,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||||
errmsg("invalid number of points in external \"path\" value")));
|
errmsg("invalid number of points in external \"path\" value")));
|
||||||
@ -3484,7 +3484,7 @@ poly_recv(PG_FUNCTION_ARGS)
|
|||||||
int size;
|
int size;
|
||||||
|
|
||||||
npts = pq_getmsgint(buf, sizeof(int32));
|
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,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||||
errmsg("invalid number of points in external \"polygon\" value")));
|
errmsg("invalid number of points in external \"polygon\" value")));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user