Skip site navigation (1) Skip section navigation (2)

Re: patch for ECPG (BUG #2956: ECPG does not treat multibyte characters correctly.)

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Michael Meskes <meskes(at)postgresql(dot)org>, pgsql-patches(at)postgresql(dot)org
Cc: harada(dot)toshi(at)oss(dot)ntt(dot)co(dot)jp
Subject: Re: patch for ECPG (BUG #2956: ECPG does not treat multibyte characters correctly.)
Date: 2007-02-27 11:51:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
Michael Meskes <meskes(at)postgresql(dot)org> wrote:

> > I found bug in ecpg concerning processing of the multi-byte character-code.
> > I reported as bug#2956 before. 
> I'm just committing the changes to CVS but only to HEAD because I cannot
> check if my changes broke something. The sources work fine on my system
> and the regression tests pass without a problem. But then I do not have
> a setup similar to yours. Could you please test this?

I tested the change and it worked fine, but I found that this fix
should be backported -- it might cause SQL injections depending on
the server configurations.

The attached patches are backports for the past releases.
I hope you will apply them. Thanks.

1. initdb --no-locale --encoding=UTF8
2. SET client_encoding = sjis in postgresql.conf
3. ecpg test.pgc
4. gcc test.c
5. test < src.sjis.txt

The first charactor is a Japanese kanji. (0x95+0x5c)

-- 8.3dev
表'; SELECT 9999;--

-- 8.2.3 : backslash_quote = safe_encoding
sql error 'unsafe use of \' in a string literal' in line 21.

-- 8.2.3 : backslash_quote = on  (SQL injection!)

-- 8.2.3 with patch : backslash_quote = safe_encoding
表'; SELECT 9999;--

ITAGAKI Takahiro
NTT Open Source Software Center

Attachment: test.pgc
Description: application/octet-stream (414 bytes)
Attachment: src.sjis.txt
Description: application/octet-stream (19 bytes)
Attachment: ecpg-quote_8.0.11-7.4.10.diff
Description: application/octet-stream (1.3 KB)
Attachment: ecpg-quote_8.1.7.diff
Description: application/octet-stream (1.6 KB)
Attachment: ecpg-quote_8.2.3.diff
Description: application/octet-stream (2.0 KB)

In response to


pgsql-patches by date

Next:From: Zdenek KotalaDate: 2007-02-27 12:42:24
Subject: Re: [PATCHES] BUG #2969: Inaccuracies in Solaris FAQ
Previous:From: Heikki LinnakangasDate: 2007-02-27 11:03:12
Subject: Re:

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group