diff options
author | Jukka Taimisto <jukka.taimisto@codenomicon.com> | 2015-01-20 11:14:27 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-01-20 12:40:40 +0200 |
commit | 4977100c5c0d843cec9d61c304dcea52db9b9053 (patch) | |
tree | b3274d6d1bf6862721ecc00fee18eb18e9bc71cc /profiles/gap | |
parent | 027a4610a720be05e0fe0b9fd74ecceabf46c9d4 (diff) | |
download | bluez-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.c | 2 |
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); |