Re: Patch: Implement failover on libpq connect level.

From: Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter van Hardenberg <pvh(at)pvh(dot)ca>, Peter Eisentraut <peter_e(at)gmx(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: Implement failover on libpq connect level.
Date: 2016-11-01 15:21:40
Message-ID: CAD__Ouh3cK2_ZAAUXt4PC4gNPYSuZJPx9nDxUNVNeaFWABbLsQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

On Tue, Nov 1, 2016 at 7:44 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> Starting program: /home/mithun/libpqbin/bin/./psql
>> postgres://%2home%2mithun:5555/postgres -U mithun1
>Can you provide a concrete test scenario or some test code that fails?
>connhost is supposed to be getting set in connectOptions2(), which is
>run (AIUI) when the PGconn is first created. So I think that it will
>be set in all scenarios of the type you mention, but I might be
>missing something.

Sorry if my sentence is confusing
If I give a proper hexadecimal encoding % followed by 2 hexadigit (i.e. for
e.g %2f, %2a) every thing is fine. When I pass a invalid hexadigit encoding
eg: *%2h, %2m *among the host string e.g
"postgres://*%2h*ome*%2m*ithun:5555/postgres".
then "PQconnectdbParams()" fails before calling connectOptions2(). In that
case failed PQconnectdbParams() also return a PGconn where connhost is not
set. If we call PQpass(), PQReset() on such a PGconn we get a crash.

A simple test case which crash is:
./psql 'postgres://%2hxxx:5555/postgres'

Call stack:
--------------
#0 0x00007ffff7bb8d4f in PQpass (conn=0x68aa10) at fe-connect.c:5582
#1 0x00007ffff7bb907a in PQconnectionNeedsPassword (conn=0x68aa10) at
fe-connect.c:5727
#2 0x00000000004130aa in main (argc=2, argv=0x7fffffffdff8) at
startup.c:250

--
Thanks and Regards
Mithun C Y
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2016-11-01 15:58:56 pgsql: Add make rules to download raw Unicode mapping files
Previous Message Alvaro Herrera 2016-11-01 15:15:03 Re: DROP FUNCTION of multiple functions

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas Kellerer 2016-11-01 15:27:52 Re: JDBC and the hstore ? operator - no longer working with build 1211
Previous Message Robert Haas 2016-11-01 14:14:03 Re: Patch: Implement failover on libpq connect level.