mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-03-24 20:40:09 +09:00
buffer: Remove support for format specifier 'F' in ssh_buffer_pack()
Eliminate dead code. Signed-off-by: Shiva Kiran Koninty <shiva_kr@riseup.net> Reviewed-by: Pavol Žáčik <pzacik@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
d680b8ea8a
commit
5ad8dda6f6
23
src/buffer.c
23
src/buffer.c
@@ -921,18 +921,10 @@ static int ssh_buffer_pack_allocate_va(struct ssh_buffer_struct *buffer,
|
||||
va_arg(ap, void *);
|
||||
count++; /* increase argument count */
|
||||
break;
|
||||
case 'F':
|
||||
case 'B':
|
||||
b = va_arg(ap, bignum);
|
||||
if (*p == 'F') {
|
||||
/* For padded bignum, we know the exact length */
|
||||
len = va_arg(ap, size_t);
|
||||
count++; /* increase argument count */
|
||||
needed_size += sizeof(uint32_t) + len;
|
||||
} else {
|
||||
/* The bignum bytes + 1 for possible padding */
|
||||
needed_size += sizeof(uint32_t) + bignum_num_bytes(b) + 1;
|
||||
}
|
||||
/* The bignum bytes + 1 for possible padding */
|
||||
needed_size += sizeof(uint32_t) + bignum_num_bytes(b) + 1;
|
||||
break;
|
||||
case 't':
|
||||
cstring = va_arg(ap, char *);
|
||||
@@ -1062,16 +1054,9 @@ ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
|
||||
rc = ssh_buffer_add_data(buffer, o.data, (uint32_t)len);
|
||||
o.data = NULL;
|
||||
break;
|
||||
case 'F':
|
||||
case 'B':
|
||||
b = va_arg(ap, bignum);
|
||||
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);
|
||||
}
|
||||
o.string = ssh_make_bignum_string(b);
|
||||
if(o.string == NULL){
|
||||
rc = SSH_ERROR;
|
||||
break;
|
||||
@@ -1127,8 +1112,6 @@ ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
|
||||
* 'P': size_t, void * (len of data, pointer to data)
|
||||
* only pushes data.
|
||||
* 'B': bignum (pushed as SSH string)
|
||||
* 'F': bignum, size_t (bignum, padded to fixed length,
|
||||
* pushed 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
|
||||
|
||||
@@ -267,10 +267,10 @@ static void torture_ssh_buffer_bignum(void **state)
|
||||
bignum num = NULL;
|
||||
int rc;
|
||||
size_t len;
|
||||
uint8_t verif[] = "\x00\x00\x00\x04" /* len 4 byte */
|
||||
"\x00\x00\x00\xff" /* padded 255 */
|
||||
"\x00\x00\x00\x02" /* len 2 byte */
|
||||
"\x00\xff"; /* padded 255 */
|
||||
uint8_t verif[] = "\x00\x00\x00\x02" /* len */
|
||||
"\x00\xff" /* pad, num */
|
||||
"\x00\x00\x00\x02" /* len */
|
||||
"\x00\xff"; /* pad, num */
|
||||
|
||||
(void)state;
|
||||
|
||||
@@ -283,20 +283,13 @@ static void torture_ssh_buffer_bignum(void **state)
|
||||
rc = bignum_set_word(num, 255);
|
||||
assert_int_equal(rc, 1);
|
||||
|
||||
rc = ssh_buffer_pack(buffer, "FB", num, (size_t)4, num);
|
||||
rc = ssh_buffer_pack(buffer, "BB", num, num);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
|
||||
len = ssh_buffer_get_len(buffer);
|
||||
assert_int_equal(len, sizeof(verif) - 1);
|
||||
assert_memory_equal(ssh_buffer_get(buffer), verif, sizeof(verif) - 1);
|
||||
|
||||
/* negative test -- this number requires 3 bytes */
|
||||
rc = bignum_set_word(num, 256 * 256);
|
||||
assert_int_equal(rc, 1);
|
||||
|
||||
rc = ssh_buffer_pack(buffer, "FB", num, (size_t)2, num);
|
||||
assert_int_equal(rc, SSH_ERROR);
|
||||
|
||||
bignum_safe_free(num);
|
||||
|
||||
SSH_BUFFER_FREE(buffer);
|
||||
|
||||
Reference in New Issue
Block a user