From 71846207ccd8f6929d3e9d84a4476882ed2a3fd1 Mon Sep 17 00:00:00 2001 From: Naresh Jayaram Date: Tue, 3 Mar 2015 15:43:17 +0530 Subject: [PATCH] qcom-softap: Replace strcat & strcpy with strlcat & strlcpy strcpy and strcat are not safe, instead use strlcpy and strlcat which have control over the number of bytes to be written to the output str or buffer. CRs-Fixed: 802872 Change-Id: I7b6748946633dda551a1015678d41846c19adeb2 --- softap/jni/QWiFiSoftApCfg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/softap/jni/QWiFiSoftApCfg.c b/softap/jni/QWiFiSoftApCfg.c index 3f991f3..9ad1e43 100755 --- a/softap/jni/QWiFiSoftApCfg.c +++ b/softap/jni/QWiFiSoftApCfg.c @@ -319,7 +319,7 @@ JNIEXPORT jstring JNICALL char code[32] = {0}; int connect_retry; - strncpy(cmd, "softap qccmd ", sizeof(cmd)); + strlcpy(cmd, "softap qccmd ", sizeof(cmd)); pcmd = (char *) ((*env)->GetStringUTFChars(env, jcmd, NULL)); @@ -330,12 +330,12 @@ JNIEXPORT jstring JNICALL ALOGD("Received Command: %s\n", pcmd); - if ((strlen(cmd) + strlen(pcmd)) > sizeof(cmd)) { + if ((strlen(cmd) + strlen(pcmd)) >= sizeof(cmd)) { UPDATE_ERROR_CODE("Command length is larger than MAX_CMD_SIZE", ""); goto end; } - strcat(cmd, pcmd); + strlcat(cmd, pcmd, sizeof(cmd)); connect_retry = 0;