diff options
author | Elliott Hughes <enh@google.com> | 2018-01-19 15:53:14 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2018-01-19 15:53:14 -0800 |
commit | ef75a2a80c51e12da9b5d46ee8ae010b267f26bb (patch) | |
tree | 2b05896c41a3a80f18ebf627e7e6412b7ea091c3 /rild | |
parent | 94ae99932786c7b3fff9379052770a5b57313c4b (diff) | |
download | android_hardware_ril-ef75a2a80c51e12da9b5d46ee8ae010b267f26bb.tar.gz android_hardware_ril-ef75a2a80c51e12da9b5d46ee8ae010b267f26bb.tar.bz2 android_hardware_ril-ef75a2a80c51e12da9b5d46ee8ae010b267f26bb.zip |
Avoid possible buffer overflow.
clang-tidy rightly complains that this code for concatenating two strings
is incorrect because it doesn't take into account the space used by the
first string when appending the second string. Just use snprintf instead.
Bug: N/A
Test: builds, boots
Change-Id: Ifdaff43a87301a876369635013516aab41cd48c3
Diffstat (limited to 'rild')
-rw-r--r-- | rild/rild.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rild/rild.c b/rild/rild.c index dbd925d..685ef70 100644 --- a/rild/rild.c +++ b/rild/rild.c @@ -144,8 +144,8 @@ int main(int argc, char **argv) { exit(0); } if (strncmp(clientId, "0", MAX_CLIENT_ID_LENGTH)) { - strncpy(ril_service_name, ril_service_name_base, MAX_SERVICE_NAME_LENGTH); - strncat(ril_service_name, clientId, MAX_SERVICE_NAME_LENGTH); + snprintf(ril_service_name, sizeof(ril_service_name), "%s%s", ril_service_name_base, + clientId); } if (rilLibPath == NULL) { |