Skip to content
Snippets Groups Projects
Commit d86dee3e authored by Bruce Momjian's avatar Bruce Momjian
Browse files

This patch should fix the problem. Doesn't include my previous patch

for repeat(). Again, somewhat off-the-cuff, so I might have missed
something...

test=# select lpad('xxxxx',1431655765,'yyyyyyyyyyyyyyyy');
ERROR:  Requested length too large
test=# select rpad('xxxxx',1431655765,'yyyyyyyyyyyyyyyy');
ERROR:  Requested length too large

(That's on a Unicode DB, haven't tested other encodings but AFAICT
this fix should still work.)

Neil Conway
parent cbe733d7
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.39 2002/08/22 04:54:20 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.40 2002/08/22 04:55:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -199,6 +199,11 @@ lpad(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
bytelen = pg_database_encoding_max_length() * len;
/* check for integer overflow */
if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
elog(ERROR, "Requested length too large");
ret = (text *) palloc(VARHDRSZ + bytelen);
#else
ret = (text *) palloc(VARHDRSZ + len);
......@@ -310,6 +315,11 @@ rpad(PG_FUNCTION_ARGS)
#ifdef MULTIBYTE
bytelen = pg_database_encoding_max_length() * len;
/* Check for integer overflow */
if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
elog(ERROR, "Requested length too large");
ret = (text *) palloc(VARHDRSZ + bytelen);
#else
ret = (text *) palloc(VARHDRSZ + len);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment