postgresql/src/backend/tcop
Tom Lane 36a3be6540 Fix new and latent bugs with errno handling in secure_read/secure_write.
These functions must be careful that they return the intended value of
errno to their callers.  There were several scenarios where this might
not happen:

1. The recent SSL renegotiation patch added a hunk of code that would
execute after setting errno.  In the first place, it's doubtful that we
should consider renegotiation to be successfully completed after a failure,
and in the second, there's no real guarantee that the called OpenSSL
routines wouldn't clobber errno.  Fix by not executing that hunk except
during success exit.

2. errno was left in an unknown state in case of an unrecognized return
code from SSL_get_error().  While this is a "can't happen" case, it seems
like a good idea to be sure we know what would happen, so reset errno to
ECONNRESET in such cases.  (The corresponding code in libpq's fe-secure.c
already did this.)

3. There was an (undocumented) assumption that client_read_ended() wouldn't
change errno.  While true in the current state of the code, this seems less
than future-proof.  Add explicit saving/restoring of errno to make sure
that changes in the called functions won't break things.

I see no need to back-patch, since #1 is new code and the other two issues
are mostly hypothetical.

Per discussion with Amit Kapila.
2013-11-24 13:09:38 -05:00
..
dest.c Add a materialized view relations. 2013-03-03 18:23:31 -06:00
fastpath.c sepgsql: Enforce db_procedure:{execute} permission. 2013-04-12 08:58:01 -04:00
Makefile Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
postgres.c Fix new and latent bugs with errno handling in secure_read/secure_write. 2013-11-24 13:09:38 -05:00
pquery.c Only install a portal's ResourceOwner if it actually has one. 2013-06-13 13:12:49 -04:00
utility.c Issue error on SET outside transaction block in some cases 2013-10-04 13:50:28 -04:00