Re: Bug #925: typing error in src/backend/libpq/be-secure.c - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: Bug #925: typing error in src/backend/libpq/be-secure.c
Date
Msg-id 200303290502.h2T52Os26779@candle.pha.pa.us
Whole thread Raw
In response to Re: Bug #925: typing error in src/backend/libpq/be-secure.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Bug #925: typing error in src/backend/libpq/be-secure.c  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Actually, the docs say SSL_read/write can error needing READ or WRITE:

    http://www.openssl.org/docs/ssl/SSL_read.html#

The SSL_write docs are the same.  I have applied the following patch to
handle both new cases.  Does this help the SSL test program you have?

---------------------------------------------------------------------------

Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Yep, typo.  Patched to CVS current and backpatched to 7.3.X.
>
> I think this fix is exactly backward.  Why would SSL_write need to
> return ERROR_WANT_WRITE?  It couldn't.  The correct fix is that
> SSL_write might return ERROR_WANT_READ, for which reading would be
> the right response.
>
> BTW the real problem, both here and elsewhere in this file, is the
> lack of a "default: elog-out" case in the switch statements.  This
> code will simply break if any unexpected case occurs.
>
>             regards, tom lane
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/libpq/be-secure.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/libpq/be-secure.c,v
retrieving revision 1.27
diff -c -c -r1.27 be-secure.c
*** src/backend/libpq/be-secure.c    29 Mar 2003 03:56:44 -0000    1.27
--- src/backend/libpq/be-secure.c    29 Mar 2003 04:59:01 -0000
***************
*** 285,290 ****
--- 285,293 ----
              case SSL_ERROR_WANT_READ:
                  n = secure_read(port, ptr, len);
                  break;
+             case SSL_ERROR_WANT_WRITE:
+                 n = secure_write(port, ptr, len);
+                 break;
              case SSL_ERROR_SYSCALL:
                  if (n == -1)
                      elog(COMMERROR, "SSL SYSCALL error: %s", strerror(errno));
***************
*** 336,341 ****
--- 339,347 ----
          {
              case SSL_ERROR_NONE:
                  port->count += n;
+                 break;
+             case SSL_ERROR_WANT_READ:
+                 n = secure_read(port, ptr, len);
                  break;
              case SSL_ERROR_WANT_WRITE:
                  n = secure_write(port, ptr, len);

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug #925: typing error in src/backend/libpq/be-secure.c
Next
From: Tom Lane
Date:
Subject: Re: Bug #925: typing error in src/backend/libpq/be-secure.c