Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c996c7f

Browse files
committed
Let's try this again on accepting the correct range of Oid input values
for 64-bit platforms ...
1 parent 0a8da82 commit c996c7f

File tree

1 file changed

+11
-4
lines changed
  • src/backend/utils/adt

1 file changed

+11
-4
lines changed

src/backend/utils/adt/oid.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.42 2000/12/22 21:36:09 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.43 2000/12/28 01:51:15 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -67,14 +67,21 @@ oidin_subr(const char *funcname, const char *s, char **endloc)
6767
result = (Oid) cvt;
6868

6969
/*
70-
* Cope with possibility that unsigned long is wider than Oid.
70+
* Cope with possibility that unsigned long is wider than Oid,
71+
* in which case strtoul will not raise an error for some values
72+
* that are out of the range of Oid.
73+
*
74+
* For backwards compatibility, we want to accept inputs that
75+
* are given with a minus sign, so allow the input value if it
76+
* matches after either signed or unsigned extension to long.
7177
*
7278
* To ensure consistent results on 32-bit and 64-bit platforms,
7379
* make sure the error message is the same as if strtoul() had
7480
* returned ERANGE.
7581
*/
76-
#if OID_MAX < ULONG_MAX
77-
if (cvt > (unsigned long) OID_MAX)
82+
#if OID_MAX != ULONG_MAX
83+
if (cvt != (unsigned long) result &&
84+
cvt != (unsigned long) ((int) result))
7885
elog(ERROR, "%s: error reading \"%s\": %s",
7986
funcname, s, strerror(ERANGE));
8087
#endif

0 commit comments

Comments
 (0)