Re: 32 bit libpq fail to connecting when set a very large "connect_timeout" value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: chenhj <chjischj(at)163(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: 32 bit libpq fail to connecting when set a very large "connect_timeout" value
Date: 2014-10-20 13:53:49
Message-ID: 3051.1413813229@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

chenhj <chjischj(at)163(dot)com> writes:
> [chenhj(at)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Steven Siebert 2014-10-20 14:11:24 Re: BUG #10680: LDAP bind password leaks to log on failed authentication
Previous Message Michael Paquier 2014-10-20 06:45:20 Re: BUG #11705: \d(escribe) table shows incorrect check constraint