From d2654ce519fb46615bdbcef77f08d47933b7e062 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 31 Jan 2017 10:22:38 +0100 Subject: [PATCH] Add null character at the end of the key when storing it in a LinphoneContent (to prevent invalid reads). --- coreapi/content.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coreapi/content.c b/coreapi/content.c index 06645e80b..a2445e35f 100644 --- a/coreapi/content.c +++ b/coreapi/content.c @@ -185,8 +185,9 @@ void linphone_content_set_key(LinphoneContent *content, const char *key, const s content->key = NULL; } if (key != NULL) { - content->key = belle_sip_malloc(keyLength); + content->key = belle_sip_malloc(keyLength + 1); memcpy(content->key, key, keyLength); + content->key[keyLength] = '\0'; content->keyLength = keyLength; } }