pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: eshkinkot@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8702: psql \df+ translate_columns[] overflow and unexpected gettext translation
Date: Fri, 27 Dec 2013 22:50:37 -0500
Message-ID: <1388202637.18242.3.camel@vanquo.pezone.net> (raw)
In-Reply-To: <E1VwKqz-0005WO-PP@wrigleys.postgresql.org>
References: <E1VwKqz-0005WO-PP@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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.

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

0001-psql-Fix-translate_columns-counts.patch (text/x-patch, 1.9K) download From 72d371b17fb22d025fc549e73aa04f5268e75ca3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter_e@gmx.net> 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

view thread (4+ messages)  latest in thread

Message-ID: <1388202637.18242.3.camel@vanquo.pezone.net>
Permalink:  ../1388202637.18242.3.camel@vanquo.pezone.net/
Also on:    postgresql.org/message-id/1388202637.18242.3.camel@vanquo.pezone.net

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: peter_e@gmx.net, eshkinkot@gmail.com
  Subject: Re: BUG #8702: psql \df+ translate_columns[] overflow and unexpected gettext translation
  In-Reply-To: <1388202637.18242.3.camel@vanquo.pezone.net>
  References: <E1VwKqz-0005WO-PP@wrigleys.postgresql.org> <1388202637.18242.3.camel@vanquo.pezone.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox