X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 774CED1B560 for ; Mon, 29 Sep 2003 16:50:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 22614-03 for ; Mon, 29 Sep 2003 13:50:18 -0300 (ADT) Received: from wind.ukr.net (wind.ukr.net [212.42.64.10]) by svr1.postgresql.org (Postfix) with ESMTP id 4760ED1B55A for ; Mon, 29 Sep 2003 13:49:37 -0300 (ADT) Received: from 82-57.odessa.dialup.ukr.net ([212.42.82.57]) by wind.ukr.net with esmtp ID 1A41DH-0004Ea-6M for pgsql-interfaces@postgresql.org; Mon, 29 Sep 2003 19:49:31 +0300 From: Igor Shevchenko To: pgsql-interfaces@postgresql.org Subject: PQescapeString handling of \0 Date: Mon, 29 Sep 2003 19:49:26 +0300 User-Agent: KMail/1.5.2 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_WKGe/Vn6DuTXsSw" Message-Id: <200309291949.26188.igor@carcass.ath.cx> X-WIND.UKR.NET-ID: 507770c60be180641177ee0b88317514 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/69 X-Sequence-Number: 4487 --Boundary-00=_WKGe/Vn6DuTXsSw Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi. Here's a patch which makes PQescapeString stop escaping when \0 is seen. Currently. if somebody passes a string with embedded \0 (for example, perl allows \0s in it's scalars and DBD::Pg does no checks), PQescapeString will return an invalid (bigger) length for \0-terminated string. -- Best regards, Igor Shevchenko --Boundary-00=_WKGe/Vn6DuTXsSw Content-Type: text/x-diff; charset="us-ascii"; name="fe-exec_pqescapestring.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fe-exec_pqescapestring.diff" --- postgresql-7.4beta3/src/interfaces/libpq/fe-exec.c 2003-09-05 05:08:36.000000000 +0300 +++ psql/src/interfaces/libpq/fe-exec.c 2003-09-29 19:40:06.481977880 +0300 @@ -2179,2 +2179,6 @@ PQescapeString(char *to, const char *fro break; + + case 0: + remaining = 0; + continue; --Boundary-00=_WKGe/Vn6DuTXsSw--