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

Commit b4f24fe

Browse files
committed
Commit updated repeat() patch, from Neil Conway
1 parent 090884b commit b4f24fe

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/backend/utils/adt/oracle_compat.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.40 2002/08/22 04:55:05 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.41 2002/08/22 05:05:19 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1008,8 +1008,14 @@ repeat(PG_FUNCTION_ARGS)
10081008
tlen = (VARHDRSZ + (count * slen));
10091009

10101010
/* Check for integer overflow */
1011-
if (slen != 0 && count != 0 && tlen / slen != count)
1012-
elog(ERROR, "Requested buffer is too large.");
1011+
if (slen != 0 && count != 0)
1012+
{
1013+
int check = count * slen;
1014+
int check2 = check + VARHDRSZ;
1015+
1016+
if ((check / slen) != count || check2 <= check)
1017+
elog(ERROR, "Requested buffer is too large.");
1018+
}
10131019

10141020
result = (text *) palloc(tlen);
10151021

0 commit comments

Comments
 (0)