diff options
author | Matt Caswell <matt@openssl.org> | 2016-09-13 09:40:38 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-09-13 09:41:21 +0100 |
commit | c0f9e23c6b8d1076796987d5a84557d410682d85 (patch) | |
tree | c3b5c83b493e08502553431d55fb0bc17b9681d0 /ssl | |
parent | df065a2b3b325fb55f085f95afbc3896b49e8f05 (diff) |
Fix a few style nits in the wpacket code
Addressing more feedback comments.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/packet.c | 11 | ||||
-rw-r--r-- | ssl/statem/statem_dtls.c | 1 | ||||
-rw-r--r-- | ssl/t1_lib.c | 1 |
3 files changed, 7 insertions, 6 deletions
diff --git a/ssl/packet.c b/ssl/packet.c index b8d1ec2c5c..b7084b0e66 100644 --- a/ssl/packet.c +++ b/ssl/packet.c @@ -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)) diff --git a/ssl/statem/statem_dtls.c b/ssl/statem/statem_dtls.c index 35f25f1f1e..25c45753fb 100644 --- a/ssl/statem/statem_dtls.c +++ b/ssl/statem/statem_dtls.c @@ -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; diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 024556e72c..50083a969d 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -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) |