Fix a few style nits in the wpacket code
authorMatt Caswell <matt@openssl.org>
Tue, 13 Sep 2016 08:40:38 +0000 (09:40 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 13 Sep 2016 08:41:21 +0000 (09:41 +0100)
Addressing more feedback comments.

Reviewed-by: Rich Salz <rsalz@openssl.org>
ssl/packet.c
ssl/statem/statem_dtls.c
ssl/t1_lib.c

index b8d1ec2c5c2512639e161d5a11a9877bab0ca104..b7084b0e6644f5bab9a55b2564cfc039c58e0363 100644 (file)
@@ -34,8 +34,8 @@ int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
         if (BUF_MEM_grow(pkt->buf, newlen) == 0)
             return 0;
     }
-    pkt->written += len;
     *allocbytes = (unsigned char *)pkt->buf->data + pkt->curr;
+    pkt->written += len;
     pkt->curr += len;
 
     return 1;
@@ -100,10 +100,10 @@ int WPACKET_set_flags(WPACKET *pkt, unsigned int flags)
     return 1;
 }
 
-/* Store the |value| of length |size| at location |data| */
-static int put_value(unsigned char *data, size_t value, size_t size)
+/* Store the |value| of length |len| at location |data| */
+static int put_value(unsigned char *data, size_t value, size_t len)
 {
-    for (data += size - 1; size > 0; size--) {
+    for (data += len - 1; len > 0; len--) {
         *data = (unsigned char)(value & 0xff);
         data--;
         value >>= 8;
@@ -127,7 +127,7 @@ static int wpacket_intern_close(WPACKET *pkt)
     size_t packlen = pkt->written - sub->pwritten;
 
     if (packlen == 0
-            && sub->flags & WPACKET_FLAGS_NON_ZERO_LENGTH)
+            && (sub->flags & WPACKET_FLAGS_NON_ZERO_LENGTH) != 0)
         return 0;
 
     if (packlen == 0
@@ -229,6 +229,7 @@ int WPACKET_put_bytes(WPACKET *pkt, unsigned int val, size_t size)
 
     /* Internal API, so should not fail */
     assert(size <= sizeof(unsigned int));
+
     if (size > sizeof(unsigned int)
             || !WPACKET_allocate_bytes(pkt, size, &data)
             || !put_value(data, val, size))
index 35f25f1f1eb1535ec5726d48806660a10180d64c..25c45753fba6c20a9147b12137f8c5e10989ceef 100644 (file)
@@ -1228,7 +1228,6 @@ int dtls1_close_construct_packet(SSL *s, WPACKET *pkt)
     s->init_off = 0;
 
     /* Buffer the message to handle re-xmits */
-
     if (!dtls1_buffer_message(s, 0))
         return 0;
 
index 024556e72c0db09f2ca628ea166fd56a6eb3c8ca..50083a969d4199bb254ac05b0a7dfbaa8524a6ca 100644 (file)
@@ -3331,6 +3331,7 @@ int tls12_copy_sigalgs(SSL *s, WPACKET *pkt,
                        const unsigned char *psig, size_t psiglen)
 {
     size_t i;
+
     for (i = 0; i < psiglen; i += 2, psig += 2) {
         if (tls12_sigalg_allowed(s, SSL_SECOP_SIGALG_SUPPORTED, psig)) {
             if (!WPACKET_put_bytes(pkt, psig[0], 1)