Skip to content

Commit c9ae257

Browse files
committed
The sanity check added to array_recv() wa a bit too tight; we must
continue to accept an empty array with dimension information. array_send() can output such arrays. Per report from Vladimir Shakhov.
1 parent 7413969 commit c9ae257

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/backend/utils/adt/arrayfuncs.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.164 2010/02/26 02:01:07 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.165 2010/08/11 19:12:27 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1213,17 +1213,21 @@ array_recv(PG_FUNCTION_ARGS)
12131213

12141214
for (i = 0; i < ndim; i++)
12151215
{
1216-
int ub;
1217-
12181216
dim[i] = pq_getmsgint(buf, 4);
12191217
lBound[i] = pq_getmsgint(buf, 4);
12201218

1221-
ub = lBound[i] + dim[i] - 1;
1222-
/* overflow? */
1223-
if (lBound[i] > ub)
1224-
ereport(ERROR,
1225-
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1226-
errmsg("integer out of range")));
1219+
/*
1220+
* Check overflow of upper bound. (ArrayNItems() below checks that
1221+
* dim[i] >= 0)
1222+
*/
1223+
if (dim[i] != 0)
1224+
{
1225+
int ub = lBound[i] + dim[i] - 1;
1226+
if (lBound[i] > ub)
1227+
ereport(ERROR,
1228+
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1229+
errmsg("integer out of range")));
1230+
}
12271231
}
12281232

12291233
/* This checks for overflow of array dimensions */

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