diff options
author | Matt Caswell <matt@openssl.org> | 2016-09-13 11:32:52 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-09-14 00:02:34 +0100 |
commit | b2b3024e0eef58589f7a49ebd48da98d4564a348 (patch) | |
tree | 579578a6ae0230d93b2817e23a18e6aa3bc97f22 /ssl/packet.c | |
parent | f1ec23c0bcc8ebb40331120b87a0e99f6823da67 (diff) |
Add a WPACKET_sub_allocate_bytes() function
Updated the construction code to use the new function. Also added some
convenience macros for WPACKET_sub_memcpy().
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl/packet.c')
-rw-r--r-- | ssl/packet.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ssl/packet.c b/ssl/packet.c index b7084b0e66..52c24769f9 100644 --- a/ssl/packet.c +++ b/ssl/packet.c @@ -41,6 +41,17 @@ int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes) return 1; } +int WPACKET_sub_allocate_bytes(WPACKET *pkt, size_t len, + unsigned char **allocbytes, size_t lenbytes) +{ + if (!WPACKET_start_sub_packet_len(pkt, lenbytes) + || !WPACKET_allocate_bytes(pkt, len, allocbytes) + || !WPACKET_close(pkt)) + return 0; + + return 1; +} + static size_t maxmaxsize(size_t lenbytes) { if (lenbytes >= sizeof(size_t) || lenbytes == 0) |