Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3d0442

Browse files
committed
Tighten up SJIS byte sequence check. Now we reject invalid SJIS byte
sequence such as "0x95 0x27". Patches from Akio Ishida.Also update copyright notice.
1 parent18bc9ea commitb3d0442

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

‎src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
*
33
* EUC_JP, SJIS and MULE_INTERNAL
44
*
5-
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
5+
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.14 2005/12/26 19:30:44 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.15 2006/03/04 10:57:35 ishii Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -22,6 +22,9 @@
2222
#definePGSJISALTCODE 0x81ac
2323
#definePGEUCALTCODE 0xa2ae
2424

25+
#defineISSJISHEAD(c) ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc))
26+
#defineISSJISTAIL(c) ((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xfc))
27+
2528
/*
2629
* conversion table between SJIS UDC (IBM kanji) and EUC_JP
2730
*/
@@ -186,6 +189,11 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
186189
* JIS X0208, X0212, user defined extended characters
187190
*/
188191
c2=*sjis++;
192+
if (!ISSJISHEAD(c1)|| !ISSJISTAIL(c2))
193+
ereport(ERROR,
194+
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
195+
errmsg("invalid byte sequence for encoding \"SJIS\": 0x%02x%02x",
196+
c1,c2)));
189197
k= (c1 <<8)+c2;
190198
/* Eiji Tokuya patched begin */
191199
if (k >=0xed40&&k<0xf040)
@@ -557,6 +565,11 @@ sjis2euc_jp(unsigned char *sjis, unsigned char *p, int len)
557565
* JIS X0208, X0212, user defined extended characters
558566
*/
559567
c2=*sjis++;
568+
if (!ISSJISHEAD(c1)|| !ISSJISTAIL(c2))
569+
ereport(ERROR,
570+
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
571+
errmsg("invalid byte sequence for encoding \"SJIS\": 0x%02x%02x",
572+
c1,c2)));
560573
k= (c1 <<8)+c2;
561574
if (k >=0xed40&&k<0xf040)
562575
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp