postgres.git / summary / log / commit / refs
commit cd99d20550a36c673cc5003c7987f816d6cd3eb3
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Sun Dec 02 12:11:15 2012 +0000
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 b8b5240d64a..cb90fa70c56 100644
--- a/src/bin/psql/psqlscan.l
+++ b/src/bin/psql/psqlscan.l
@@ -1702,7 +1702,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: b4cad625113e]