[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Fri May 27 09:01:50 UTC 2016


The branch master has been updated
       via  753be41d592e53189fc3905a2d45fd51de9aeaea (commit)
      from  ea32151f7b9353f8906188d007c6893704ac17bb (commit)


- Log -----------------------------------------------------------------
commit 753be41d592e53189fc3905a2d45fd51de9aeaea
Author: Matt Caswell <matt at openssl.org>
Date:   Thu May 26 14:47:17 2016 +0100

    Fix some suspect warnings on Windows
    
    Windows was complaining about a unary minus operator being applied to an
    unsigned type. It did seem to go on and do the right thing anyway, but the
    code does look a little suspect. This fixes it.
    
    Reviewed-by: Viktor Dukhovni <viktor at openssl.org>

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

Summary of changes:
 ssl/record/rec_layer_d1.c | 2 +-
 ssl/record/rec_layer_s3.c | 8 ++++----
 ssl/record/record_locl.h  | 1 +
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c
index 577fdfc..a7cffc8 100644
--- a/ssl/record/rec_layer_d1.c
+++ b/ssl/record/rec_layer_d1.c
@@ -464,7 +464,7 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
 
         memcpy(buf, &(SSL3_RECORD_get_data(rr)[SSL3_RECORD_get_off(rr)]), n);
         if (!peek) {
-            SSL3_RECORD_add_length(rr, -n);
+            SSL3_RECORD_sub_length(rr, n);
             SSL3_RECORD_add_off(rr, n);
             if (SSL3_RECORD_get_length(rr) == 0) {
                 s->rlayer.rstate = SSL_ST_READ_HEADER;
diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index dd4869c..8c02efd 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -201,7 +201,7 @@ int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold)
     left = rb->left;
 #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
     align = (size_t)rb->buf + SSL3_RT_HEADER_LENGTH;
-    align = (0-align) & (SSL3_ALIGN_PAYLOAD - 1);
+    align = SSL3_ALIGN_PAYLOAD - 1 - ((align - 1) % SSL3_ALIGN_PAYLOAD);
 #endif
 
     if (!extend) {
@@ -711,7 +711,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
          * payload, then we can just pretend we simply have two headers.
          */
         align = (size_t)SSL3_BUFFER_get_buf(wb) + 2 * SSL3_RT_HEADER_LENGTH;
-        align = (0-align) & (SSL3_ALIGN_PAYLOAD - 1);
+        align = SSL3_ALIGN_PAYLOAD - 1 - ((align - 1) % SSL3_ALIGN_PAYLOAD);
 #endif
         outbuf[0] = SSL3_BUFFER_get_buf(wb) + align;
         SSL3_BUFFER_set_offset(wb, align);
@@ -724,7 +724,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
             wb = &s->rlayer.wbuf[j];
 #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
             align = (size_t)SSL3_BUFFER_get_buf(wb) + SSL3_RT_HEADER_LENGTH;
-            align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
+            align = SSL3_ALIGN_PAYLOAD - 1 - ((align - 1) % SSL3_ALIGN_PAYLOAD);
 #endif
             outbuf[j] = SSL3_BUFFER_get_buf(wb) + align;
             SSL3_BUFFER_set_offset(wb, align);
@@ -1131,7 +1131,7 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
             memcpy(buf, &(rr->data[rr->off]), n);
             buf += n;
             if (!peek) {
-                SSL3_RECORD_add_length(rr, -n);
+                SSL3_RECORD_sub_length(rr, n);
                 SSL3_RECORD_add_off(rr, n);
                 if (SSL3_RECORD_get_length(rr) == 0) {
                     s->rlayer.rstate = SSL_ST_READ_HEADER;
diff --git a/ssl/record/record_locl.h b/ssl/record/record_locl.h
index 9881d61..67ae1f4 100644
--- a/ssl/record/record_locl.h
+++ b/ssl/record/record_locl.h
@@ -76,6 +76,7 @@ int ssl3_release_write_buffer(SSL *s);
 #define SSL3_RECORD_get_length(r)               ((r)->length)
 #define SSL3_RECORD_set_length(r, l)            ((r)->length = (l))
 #define SSL3_RECORD_add_length(r, l)            ((r)->length += (l))
+#define SSL3_RECORD_sub_length(r, l)            ((r)->length -= (l))
 #define SSL3_RECORD_get_data(r)                 ((r)->data)
 #define SSL3_RECORD_set_data(r, d)              ((r)->data = (d))
 #define SSL3_RECORD_get_input(r)                ((r)->input)


More information about the openssl-commits mailing list