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
This commit is contained in:
Naresh Jayaram
2015-03-03 15:43:17 +05:30
parent 120aeacf0f
commit 71846207cc

View File

@@ -319,7 +319,7 @@ JNIEXPORT jstring JNICALL
char code[32] = {0}; char code[32] = {0};
int connect_retry; int connect_retry;
strncpy(cmd, "softap qccmd ", sizeof(cmd)); strlcpy(cmd, "softap qccmd ", sizeof(cmd));
pcmd = (char *) ((*env)->GetStringUTFChars(env, jcmd, NULL)); pcmd = (char *) ((*env)->GetStringUTFChars(env, jcmd, NULL));
@@ -330,12 +330,12 @@ JNIEXPORT jstring JNICALL
ALOGD("Received Command: %s\n", pcmd); 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", ""); UPDATE_ERROR_CODE("Command length is larger than MAX_CMD_SIZE", "");
goto end; goto end;
} }
strcat(cmd, pcmd); strlcat(cmd, pcmd, sizeof(cmd));
connect_retry = 0; connect_retry = 0;