diff options
author | Matt Johnston <matt@ucc.asn.au> | 2020-05-19 00:31:41 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2020-05-19 00:31:41 +0800 |
commit | 5acee497bf3e44d86bdecf5bfa35042c363ab753 (patch) | |
tree | 8576a44683dda3c007bfec6b48831f2c31268044 /buffer.c | |
parent | 972d723484d89c71e73ed63cc17bb2a6ce8cca5a (diff) |
ext-info handling for server-sig-algs
only client side is handled
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -228,19 +228,37 @@ char* buf_getstring(buffer* buf, unsigned int *retlen) { } /* Return a string as a newly allocated buffer */ -buffer * buf_getstringbuf(buffer *buf) { +static buffer * buf_getstringbuf_int(buffer *buf, int incllen) { buffer *ret = NULL; unsigned int len = buf_getint(buf); + int extra = 0; if (len > MAX_STRING_LEN) { dropbear_exit("String too long"); } - ret = buf_new(len); + if (incllen) { + extra = 4; + } + ret = buf_new(len+extra); + if (incllen) { + buf_putint(ret, len); + } memcpy(buf_getwriteptr(ret, len), buf_getptr(buf, len), len); buf_incrpos(buf, len); buf_incrlen(ret, len); + buf_setpos(ret, 0); return ret; } +/* Return a string as a newly allocated buffer */ +buffer * buf_getstringbuf(buffer *buf) { + return buf_getstringbuf_int(buf, 0); +} + +/* Returns a string in a new buffer, including the length */ +buffer * buf_getbuf(buffer *buf) { + return buf_getstringbuf_int(buf, 1); +} + /* Just increment the buffer position the same as if we'd used buf_getstring, * but don't bother copying/malloc()ing for it */ void buf_eatstring(buffer *buf) { |