summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/buffer.c9
-rw-r--r--tests/unittests/torture_buffer.c5
2 files changed, 11 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c
index beaa44bb..8b778479 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -723,6 +723,12 @@ int ssh_buffer_pack_va(struct ssh_buffer_struct *buffer, const char *format, va_
rc = buffer_add_ssh_string(buffer, o.string);
SAFE_FREE(o.string);
break;
+ case 't':
+ cstring = va_arg(ap, char *);
+ len = strlen(cstring);
+ rc = ssh_buffer_add_data(buffer, cstring, len);
+ cstring = NULL;
+ break;
default:
SSH_LOG(SSH_LOG_WARN, "Invalid buffer format %c", *p);
rc = SSH_ERROR;
@@ -753,9 +759,10 @@ int ssh_buffer_pack_va(struct ssh_buffer_struct *buffer, const char *format, va_
* 'q': uint64_t (pushed in network byte order)
* 'S': ssh_string
* 's': char * (C string, pushed as SSH string)
+ * 't': char * (C string, pushed as free text)
* 'P': size_t, void * (len of data, pointer to data)
* only pushes data.
- * 'S': bignum (pushed as SSH string)
+ * 'B': bignum (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
diff --git a/tests/unittests/torture_buffer.c b/tests/unittests/torture_buffer.c
index c0684642..ad4dcc4e 100644
--- a/tests/unittests/torture_buffer.c
+++ b/tests/unittests/torture_buffer.c
@@ -135,14 +135,15 @@ static void torture_buffer_add_format(void **state) {
"\xac\xbd\xce\xdf"
"\x00\x00\x00\x06" "libssh"
"\x00\x00\x00\x05" "rocks"
- "So much";
+ "So much"
+ "Fun!";
b=0x42;
w=0x1337;
d=0xbadc0de;
q=0x13243546acbdcedf;
s=ssh_string_from_char("libssh");
- rc=ssh_buffer_pack(buffer, "bwdqSsP",b,w,d,q,s,"rocks",7,"So much");
+ rc=ssh_buffer_pack(buffer, "bwdqSsPt",b,w,d,q,s,"rocks",7,"So much","Fun!");
assert_int_equal(rc, SSH_OK);
len = buffer_get_rest_len(buffer);