mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
buffer.c: Support 'F' for padded bignums
Signed-off-by: Simon Josefsson <simon@josefsson.org> Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
16fd55b4b2
commit
fbf02d5936
20
src/buffer.c
20
src/buffer.c
@@ -872,13 +872,20 @@ static int ssh_buffer_pack_allocate_va(struct ssh_buffer_struct *buffer,
|
|||||||
va_arg(ap, void *);
|
va_arg(ap, void *);
|
||||||
count++; /* increase argument count */
|
count++; /* increase argument count */
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
case 'B':
|
case 'B':
|
||||||
va_arg(ap, bignum);
|
va_arg(ap, bignum);
|
||||||
/*
|
/*
|
||||||
* Use a fixed size for a bignum
|
* Use a fixed size for a bignum
|
||||||
* (they should normally be around 32)
|
* (they should normally be around 32)
|
||||||
*/
|
*/
|
||||||
needed_size += 64;
|
if (*p == 'F') {
|
||||||
|
len = va_arg(ap, size_t);
|
||||||
|
count++; /* increase argument count */
|
||||||
|
needed_size += sizeof(uint32_t) + len;
|
||||||
|
} else {
|
||||||
|
needed_size += 64;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
cstring = va_arg(ap, char *);
|
cstring = va_arg(ap, char *);
|
||||||
@@ -1008,9 +1015,16 @@ ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
|
|||||||
rc = ssh_buffer_add_data(buffer, o.data, (uint32_t)len);
|
rc = ssh_buffer_add_data(buffer, o.data, (uint32_t)len);
|
||||||
o.data = NULL;
|
o.data = NULL;
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
case 'B':
|
case 'B':
|
||||||
b = va_arg(ap, bignum);
|
b = va_arg(ap, bignum);
|
||||||
o.string = ssh_make_bignum_string(b);
|
if (*p == 'F') {
|
||||||
|
len = va_arg(ap, size_t);
|
||||||
|
count++; /* increase argument count */
|
||||||
|
o.string = ssh_make_padded_bignum_string(b, len);
|
||||||
|
} else {
|
||||||
|
o.string = ssh_make_bignum_string(b);
|
||||||
|
}
|
||||||
if(o.string == NULL){
|
if(o.string == NULL){
|
||||||
rc = SSH_ERROR;
|
rc = SSH_ERROR;
|
||||||
break;
|
break;
|
||||||
@@ -1066,6 +1080,8 @@ ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
|
|||||||
* 'P': size_t, void * (len of data, pointer to data)
|
* 'P': size_t, void * (len of data, pointer to data)
|
||||||
* only pushes data.
|
* only pushes data.
|
||||||
* 'B': bignum (pushed as SSH string)
|
* 'B': bignum (pushed as SSH string)
|
||||||
|
* 'F': bignum, size_t (bignum, padded to fixed length,
|
||||||
|
* pushed as SSH string)
|
||||||
* @returns SSH_OK on success
|
* @returns SSH_OK on success
|
||||||
* SSH_ERROR on error
|
* SSH_ERROR on error
|
||||||
* @warning when using 'P' with a constant size (e.g. 8), do not
|
* @warning when using 'P' with a constant size (e.g. 8), do not
|
||||||
|
|||||||
Reference in New Issue
Block a user