diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 6180a48e6..33bf187b9 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -950,7 +950,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input, goto out; if (chopper->output->len) - bencode_dictionary_add_string(output, "sdp", chopper->output->str); + bencode_dictionary_add_string_len(output, "sdp", chopper->output->str, chopper->output->len); errstr = NULL; out: diff --git a/include/bencode.h b/include/bencode.h index 0b27ca1ed..70eb1f4a1 100644 --- a/include/bencode.h +++ b/include/bencode.h @@ -126,6 +126,7 @@ bencode_item_t *bencode_dictionary_add_len(bencode_item_t *dict, const char *key * bencode_buffer_t object. */ INLINE bencode_item_t *bencode_dictionary_add_string(bencode_item_t *dict, const char *key, const char *val); INLINE bencode_item_t *bencode_dictionary_add_string_dup(bencode_item_t *dict, const char *key, const char *val); +INLINE bencode_item_t *bencode_dictionary_add_string_len(bencode_item_t *dict, const char *key, const char *val, int len); /* Ditto, but for a "str" object */ INLINE bencode_item_t *bencode_dictionary_add_str(bencode_item_t *dict, const char *key, const str *val); @@ -407,6 +408,12 @@ INLINE bencode_item_t *bencode_dictionary_add_string(bencode_item_t *dict, const return bencode_dictionary_add(dict, key, bencode_string(bencode_item_buffer(dict), val)); } +INLINE bencode_item_t *bencode_dictionary_add_string_len(bencode_item_t *dict, const char *key, const char *val, int len) { + if (!val) + return NULL; + return bencode_dictionary_add(dict, key, bencode_string_len(bencode_item_buffer(dict), val, len)); +} + INLINE bencode_item_t *bencode_dictionary_add_string_dup(bencode_item_t *dict, const char *key, const char *val) { if (!val) return NULL;