diff options
author | Tatsuo Ishii | 2006-03-04 12:32:59 +0000 |
---|---|---|
committer | Tatsuo Ishii | 2006-03-04 12:32:59 +0000 |
commit | 52c4e32d5f578369cf28157d7f5c3aa48762aa96 (patch) | |
tree | 33b0be9a7a0493da2936fa67b845cc3e83bc06a3 /src | |
parent | 11b347267294ab2f9db42440fc2be6035f59bf28 (diff) |
Tighten up SJIS byte sequence check. Now we reject invalid SJIS byte
sequence such as "0x95 0x27". Patches from Akio Ishida.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c index e9fd625b0bb..155eb66b2bf 100644 --- a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c +++ b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.5.2.1 2005/06/11 07:44:40 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.5.2.2 2006/03/04 12:32:59 ishii Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,9 @@ #define PGSJISALTCODE 0x81ac #define PGEUCALTCODE 0xa2ae +#define ISSJISHEAD(c) ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xef)) +#define ISSJISTAIL(c) ((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xfc)) + /* * conversion table between SJIS UDC (IBM kanji) and EUC_JP */ @@ -192,6 +195,10 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len) * JIS X0208, X0212, user defined extended characters */ c2 = *sjis++; + if (!ISSJISHEAD(c1) || !ISSJISTAIL(c2)) + elog(ERROR,"invalid byte sequence for encoding \"SJIS\": 0x%02x%02x", + c1, c2); + k = (c1 << 8) + c2; /* Eiji Tokuya patched begin */ if (k >= 0xed40 && k < 0xf040) |