Re: 32 bit libpq fail to connecting when set a very large "connect_timeout" value - Mailing list pgsql-bugs

From Tom Lane
Subject Re: 32 bit libpq fail to connecting when set a very large "connect_timeout" value
Date
Msg-id 3051.1413813229@sss.pgh.pa.us
Whole thread Raw
In response to 32 bit libpq fail to connecting when set a very large "connect_timeout" value  (chenhj <chjischj@163.com>)
Responses Re: 32 bit libpq fail to connecting when set a very large "connect_timeout" value  (chenhj <chjischj@163.com>)
List pgsql-bugs
chenhj <chjischj@163.com> writes:
> [chenhj@node2 ~]$ export PGCONNECT_TIMEOUT=2147483647

That's a pretty darn silly setting, wouldn't you agree?

> finish_time = time(NULL) + timeout;
> if(finish_time < ((time_t) 0))
> {
>    finish_time = ((time_t) -1);
> }

I don't care for this "fix" because it assumes that all current and future
time_t's are positive.  On 32-bit machines that would break in 2038 ...
unless time_t is redefined as unsigned 32-bit, in which case the test
becomes useless.

It might be possible to develop a test for overflow that would work
regardless of the width or signedness of time_t, but ISTM the work would
be vastly out of proportion to the benefit.  And you'd still not have
dealt with PGCONNECT_TIMEOUT > 2^31, which arguably is another "bug"
case here.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #11705: \d(escribe) table shows incorrect check constraint
Next
From: Steven Siebert
Date:
Subject: Re: BUG #10680: LDAP bind password leaks to log on failed authentication