Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VwkvG-0007q9-H4 for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Dec 2013 03:50:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VwkvF-0004QE-M5 for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Dec 2013 03:50:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VwkvD-0004Q5-KZ for pgsql-bugs@postgresql.org; Sat, 28 Dec 2013 03:50:43 +0000 Received: from mout.gmx.net ([212.227.15.18]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VwkvB-0003hs-44 for pgsql-bugs@postgresql.org; Sat, 28 Dec 2013 03:50:43 +0000 Received: from [10.0.0.9] ([67.165.8.132]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0MCtNr-1VniNY2Jn9-009fx2 for ; Sat, 28 Dec 2013 04:50:39 +0100 Message-ID: <1388202637.18242.3.camel@vanquo.pezone.net> Subject: Re: BUG #8702: psql \df+ translate_columns[] overflow and unexpected gettext translation From: Peter Eisentraut To: eshkinkot@gmail.com Cc: pgsql-bugs@postgresql.org Date: Fri, 27 Dec 2013 22:50:37 -0500 In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-jPCtTZqkdtOBqr27VuAH" X-Mailer: Evolution 3.8.5-2+b1 Mime-Version: 1.0 X-Provags-ID: V03:K0:pYOA6DFvB/lTSk/+WAM96FWrkKAeuBLDFTplgOPU1KjM733N9bS ggiBNSRu97pCWJOMncHMl4VDb9YwfR/wBPNlizRaVtHeKTrOBTU1wHrZ74Cs/aOCC72+zco /4pc/I4q05R+jOgzifP0GHhHUZDDUwfWZROkxc0OHlm8hLcdw9/eMzN95GCJaBgq3uzTSeo 6UnE/cprFWxnP3PoyXaGg== X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --=-jPCtTZqkdtOBqr27VuAH Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On Fri, 2013-12-27 at 00:00 +0000, eshkinkot@gmail.com wrote: > I get this result from \df+ foo: > --- echo $LANG > --- ru_RU.UTF-8 > --- > --- create function foo() returns void language plpgsql as $$ begin end $$; > src/bin/psql/describe.c:describeFunctions translate_columns[] array size > is less than the maximum number of columns in query and it overflowed in > src/bin/psql/print.c:printQuery at > ... > translate = (opt->translate_columns && > opt->translate_columns[c]); > ... > so in my case opt->translate_columns[10] have garbage == true and > "Description" field > content translated unexpectedly. There are several places that are similarly broken. See attached patch. Obviously, this is not a very robust programming interface, if the same mistake has been repeated three times independently. --=-jPCtTZqkdtOBqr27VuAH Content-Disposition: attachment; filename="0001-psql-Fix-translate_columns-counts.patch" Content-Type: text/x-patch; name="0001-psql-Fix-translate_columns-counts.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit From 72d371b17fb22d025fc549e73aa04f5268e75ca3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 27 Dec 2013 22:44:02 -0500 Subject: [PATCH] psql: Fix translate_columns counts In several places, the translate_columns were not updated when new columns were added to the display. This can lead to garbage being used. Relevant previous commits: - c9ac00e6ecfaad4d6a3e1ee478b912c7227ae62a (9.2) - 3b17efdfdd846c9bfad1637686e6f18198ea3df5 (9.2) - 89368676273a4455a20eea61b8c2f30190a223ec (9.3) --- src/bin/psql/describe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 96322ca..756d752 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -224,7 +224,7 @@ static bool describeOneTSConfig(const char *oid, const char *nspname, PQExpBufferData buf; PGresult *res; printQueryOpt myopt = pset.popt; - static const bool translate_columns[] = {false, false, false, false, true, true, false, false, false, false}; + static const bool translate_columns[] = {false, false, false, false, true, true, false, false, false, false, false}; if (strlen(functypes) != strspn(functypes, "antwS+")) { @@ -2999,7 +2999,7 @@ static bool describeOneTSConfig(const char *oid, const char *nspname, PQExpBufferData buf; PGresult *res; printQueryOpt myopt = pset.popt; - static const bool translate_columns[] = {false, false, false, false, true}; + static const bool translate_columns[] = {false, false, false, false, true, false}; initPQExpBuffer(&buf); @@ -3134,7 +3134,7 @@ static bool describeOneTSConfig(const char *oid, const char *nspname, PQExpBufferData buf; PGresult *res; printQueryOpt myopt = pset.popt; - static const bool translate_columns[] = {false, false, false, true}; + static const bool translate_columns[] = {false, false, false, true, false}; initPQExpBuffer(&buf); -- 1.8.5.1 --=-jPCtTZqkdtOBqr27VuAH Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --=-jPCtTZqkdtOBqr27VuAH--