Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YBozb-0000zs-Vh for pgsql-odbc@arkaria.postgresql.org; Thu, 15 Jan 2015 18:18:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YBozb-0004la-Fa for pgsql-odbc@arkaria.postgresql.org; Thu, 15 Jan 2015 18:18:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YBoza-0004lU-Ll for pgsql-odbc@postgresql.org; Thu, 15 Jan 2015 18:18:02 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YBozV-00013r-4n for pgsql-odbc@postgresql.org; Thu, 15 Jan 2015 18:18:01 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id BEA4328B7F; Thu, 15 Jan 2015 10:17:50 -0800 (PST) Received: from EX13-CAS-001.vmware.com (EX13-CAS-001.vmware.com [10.113.191.51]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id B6F8E41241; Thu, 15 Jan 2015 10:17:50 -0800 (PST) Received: from [192.168.1.90] (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.913.22; Thu, 15 Jan 2015 10:17:49 -0800 Message-ID: <54B80437.7090406@vmware.com> Date: Thu, 15 Jan 2015 20:17:27 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: Alvaro Herrera CC: "Faith, Jeremy" , "pgsql-odbc@postgresql.org" Subject: Re: SQL_CURSOR_TYPE prepare execute issue References: <55BAADA01D8C504993894EAEA7517CF80D07AD@003FCH1MPN2-002.003f.mgd2.msft.net> <54B5A38B.4030306@vmware.com> <55BAADA01D8C504993894EAEA7517CF80D08BD@003FCH1MPN2-002.003f.mgd2.msft.net> <54B79C0A.8010703@vmware.com> <20150115160237.GQ1663@alvh.no-ip.org> In-Reply-To: <20150115160237.GQ1663@alvh.no-ip.org> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org On 01/15/2015 06:02 PM, Alvaro Herrera wrote: > Heikki Linnakangas wrote: > >>> I have had a quick look over the change and it looks ok to me. Something of a clean up and simplification as well. >>> If I understand it correctly, the only things that don't get quoted are SQL_INTEGER and SQL_SMALLINT that pass the new valid_int_literal() test. >>> The only thing I can see that could pass that test and not be a valid integer would be a single minus char i.e. "-" >>> not sure if there is anyway that could be vulnerable though. >> >> Ah, good catch. That is definitely a problem. Consider: >> >> SELECT * FROM foo WHERE 1-? > 0 >> >> If you replace ? with -, it becomes "--", which comments out the rest of the >> query. That's actually a problem with any negative number. >> >> It would be tempting to just always quote the value, but that again would >> lead to subtle changes in the datatype that the server chooses. > > Maybe you can "quote" it with whitespace, so that it becomes > > SELECT * FROM foo WHERE 1- -1 > 0 > > which is no longer a comment and has no other side effect. Hmm. Strictly speaking, -1 is interpreted as -(1) by the server. Usually it doesn't make any difference, but see: postgres=# select -32768::smallint; ERROR: smallint out of range postgres=# select (-32768)::smallint; int2 -------- -32768 (1 row) It also affects the automatically chosen column name: postgres=# select -1::int4; ?column? ---------- -1 (1 row) postgres=# select (-1)::int4; int4 ------ -1 (1 row) On the whole, using parens seems better. - Heikki -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc