Skip to content

Commit 4d924bd

Browse files
committed
Tighten up overflow check in path_recv, pursuant to code review inspired
by Ken Ashcraft's report. I think there is no actual bug here since if the int32 value does wrap a little bit, palloc will still reject it. Still it's better that the code be obviously correct.
1 parent 0a54441 commit 4d924bd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/utils/adt/geo_ops.c

Lines changed: 2 additions & 2 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.83 2003/11/29 19:51:58 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.84 2004/05/12 22:38:44 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1383,7 +1383,7 @@ path_recv(PG_FUNCTION_ARGS)
13831383

13841384
closed = pq_getmsgbyte(buf);
13851385
npts = pq_getmsgint(buf, sizeof(int32));
1386-
if (npts < 0 || npts >= (int32) (INT_MAX / sizeof(Point)))
1386+
if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point)))
13871387
ereport(ERROR,
13881388
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
13891389
errmsg("invalid number of points in external \"path\" value")));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy