postgres.git / summary / log / commit / refs
commit eb851c998d2a37a6512a26dba11a303babe6316a
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Sun Dec 02 12:11:15 2012 +0000
First released in: 9.3.0, 8.3.22, 8.4.15, 9.0.11, 9.1.7, 9.2.2
Fix psql crash while parsing SQL file whose encoding is different from
client encoding and the client encoding is not *safe* one. Such an
example is, file encoding is UTF-8 and client encoding SJIS. Patch
contributed by Jiang Guiqing.
src/bin/psql/psqlscan.l | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l
index e89f2d9bd6e..36902210b8a 100644
--- a/src/bin/psql/psqlscan.l
+++ b/src/bin/psql/psqlscan.l
@@ -1656,7 +1656,7 @@ prepare_buffer(const char *txt, int len, char **txtcopy)
/* first byte should always be okay... */
newtxt[i] = txt[i];
i++;
- while (--thislen > 0)
+ while (--thislen > 0 && i < len)
newtxt[i++] = (char) 0xFF;
}
}
[parent: 9009ec051554]