Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd86dee3

Browse files
committed
This patch should fix the problem. Doesn't include my previous patch
for repeat(). Again, somewhat off-the-cuff, so I might have missedsomething...test=# select lpad('xxxxx',1431655765,'yyyyyyyyyyyyyyyy');ERROR: Requested length too largetest=# select rpad('xxxxx',1431655765,'yyyyyyyyyyyyyyyy');ERROR: Requested length too large(That's on a Unicode DB, haven't tested other encodings but AFAICTthis fix should still work.)Neil Conway
1 parentcbe733d commitd86dee3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/backend/utils/adt/oracle_compat.c‎

Lines changed: 11 additions & 1 deletion
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.39 2002/08/22 04:54:20 momjian Exp $
12+
*$Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.40 2002/08/22 04:55:05 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -199,6 +199,11 @@ lpad(PG_FUNCTION_ARGS)
199199

200200
#ifdefMULTIBYTE
201201
bytelen=pg_database_encoding_max_length()*len;
202+
203+
/* check for integer overflow */
204+
if (len!=0&&bytelen /pg_database_encoding_max_length()!=len)
205+
elog(ERROR,"Requested length too large");
206+
202207
ret= (text*)palloc(VARHDRSZ+bytelen);
203208
#else
204209
ret= (text*)palloc(VARHDRSZ+len);
@@ -310,6 +315,11 @@ rpad(PG_FUNCTION_ARGS)
310315

311316
#ifdefMULTIBYTE
312317
bytelen=pg_database_encoding_max_length()*len;
318+
319+
/* Check for integer overflow */
320+
if (len!=0&&bytelen /pg_database_encoding_max_length()!=len)
321+
elog(ERROR,"Requested length too large");
322+
313323
ret= (text*)palloc(VARHDRSZ+bytelen);
314324
#else
315325
ret= (text*)palloc(VARHDRSZ+len);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp