patch to disallow zero length paths in binary (minor bug fix)

Started by Merlin Moncureover 18 years ago2 messagespatches
Jump to latest
#1Merlin Moncure
mmoncure@gmail.com

Hackers,

Following is a patch to force the path type not to accept a path with
zero points. This appears to be illegal in the parser, but possible
when sending a well formed packed in binary with zero points. The old
behavior was this:

ERROR: floating-point exception
DETAIL: An invalid floating-point operation was signaled. This probably
means an out-of-range result or an invalid operation, such as division
by zero.

now it should properly display the points out of range error

merlin
eSilo

Index: src/backend/utils/adt/geo_ops.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v
retrieving revision 1.97
diff -r1.97 geo_ops.c
1459c1459
<   if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0]))
/ sizeof(Point)))
---
Show quoted text

if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point)))

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Merlin Moncure (#1)
Re: patch to disallow zero length paths in binary (minor bug fix)

"Merlin Moncure" <mmoncure@gmail.com> writes:

Following is a patch to force the path type not to accept a path with
zero points. This appears to be illegal in the parser, but possible
when sending a well formed packed in binary with zero points.

Hmm, looks like poly_recv has the same mistake.

Ideally I think it'd be a good idea if these types did allow zero
elements, but that would clearly be a feature extension more than a bug
fix, since the implications aren't entirely obvious. I concur with
disallowing the case for existing branches. Will go apply.

regards, tom lane