diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2016-01-01 21:51:15 +0100 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2016-05-13 09:48:55 +0200 |
commit | 5dbe986969ae071e518acad0c049a8033c179392 (patch) | |
tree | 2f202f583eeae87495649611a8d35444a25fa5ba | |
parent | b3c37f06d3d3afb7f67530c772982ff3433215ba (diff) | |
download | libssh-5dbe986969ae071e518acad0c049a8033c179392.tar.gz libssh-5dbe986969ae071e518acad0c049a8033c179392.tar.xz libssh-5dbe986969ae071e518acad0c049a8033c179392.zip |
buffer_unpack: support bignums
-rw-r--r-- | src/buffer.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index 9897f391..7adf8bc8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -828,9 +828,11 @@ int ssh_buffer_unpack_va(struct ssh_buffer_struct *buffer, uint64_t *qword; ssh_string *string; char **cstring; + bignum *bignum; void **data; } o; size_t len, rlen; + ssh_string tmp_string; va_list ap_copy; int count; @@ -868,6 +870,18 @@ int ssh_buffer_unpack_va(struct ssh_buffer_struct *buffer, *o.qword = ntohll(*o.qword); rc = rlen==8 ? SSH_OK : SSH_ERROR; break; + case 'B': + o.bignum = va_arg(ap, bignum *); + *o.bignum = NULL; + tmp_string = ssh_buffer_get_ssh_string(buffer); + if (tmp_string == NULL){ + rc = SSH_ERROR; + break; + } + *o.bignum = ssh_make_string_bn(tmp_string); + ssh_string_free(tmp_string); + rc = (*o.bignum != NULL)? SSH_OK : SSH_ERROR; + break; case 'S': o.string = va_arg(ap, ssh_string *); *o.string = ssh_buffer_get_ssh_string(buffer); @@ -998,6 +1012,7 @@ int ssh_buffer_unpack_va(struct ssh_buffer_struct *buffer, * 's': char ** (C string, pulled as SSH string) * 'P': size_t, void ** (len of data, pointer to data) * only pulls data. + * 'B': bignum * (pulled as SSH string) * @returns SSH_OK on success * SSH_ERROR on error * @warning when using 'P' with a constant size (e.g. 8), do not |