mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-09 08:10:09 +08:00
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
This commit is contained in:
parent
cbe733d752
commit
d86dee3edd
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user