summaryrefslogtreecommitdiff
path: root/profiles/gap
diff options
context:
space:
mode:
authorJukka Taimisto <jukka.taimisto@codenomicon.com>2015-01-20 11:14:27 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2015-01-20 12:40:40 +0200
commit4977100c5c0d843cec9d61c304dcea52db9b9053 (patch)
treeb3274d6d1bf6862721ecc00fee18eb18e9bc71cc /profiles/gap
parent027a4610a720be05e0fe0b9fd74ecceabf46c9d4 (diff)
downloadbluez-4977100c5c0d843cec9d61c304dcea52db9b9053.tar.gz
profiles/gap: Make sure device name is null -terminated.
If value of device name characteristic does not contain valid UTF-8 characters, make sure the name is null terminated before converting non-ascii characters to spaces.
Diffstat (limited to 'profiles/gap')
-rw-r--r--profiles/gap/gas.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c
index 762e352ac..90b2b4f2e 100644
--- a/profiles/gap/gas.c
+++ b/profiles/gap/gas.c
@@ -81,6 +81,8 @@ static char *name2utf8(const uint8_t *name, uint8_t len)
if (g_utf8_validate((const char *) name, len, NULL))
return g_strndup((char *) name, len);
+ len = MIN(len, sizeof(utf8_name) - 1);
+
memset(utf8_name, 0, sizeof(utf8_name));
strncpy(utf8_name, (char *) name, len);