Swap the check in ssl3_write_pending to avoid using
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 9 Feb 2018 17:09:59 +0000 (18:09 +0100)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 9 Feb 2018 18:54:03 +0000 (19:54 +0100)
the possibly indeterminate pointer value in wpend_buf.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5307)

ssl/record/rec_layer_s3.c

index 3a0ed744ab3db943ff56404daa9b38837571b3a9..3cfefb3f0f8ecd9189738ee31494fce347e1e568 100644 (file)
@@ -894,10 +894,9 @@ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
     SSL3_BUFFER *wb = s->rlayer.wbuf;
     unsigned int currbuf = 0;
 
-/* XXXX */
     if ((s->rlayer.wpend_tot > (int)len)
-        || ((s->rlayer.wpend_buf != buf) &&
-            !(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER))
+        || (!(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)
+            && (s->rlayer.wpend_buf != buf))
         || (s->rlayer.wpend_type != type)) {
         SSLerr(SSL_F_SSL3_WRITE_PENDING, SSL_R_BAD_WRITE_RETRY);
         return (-1);