From: Seongil Hahm Date: Thu, 14 Sep 2017 09:35:15 +0000 (-0700) Subject: Fix Svace issues in wifi_test.c X-Git-Tag: 1.1_Public_Release~224^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d8d47355afbcaf4449186d4acf1b403353d60b8a;p=rtos%2Ftinyara.git Fix Svace issues in wifi_test.c 1. use strncat instead of strcat. 2. use snprintf instead of sprintf 3. close socket fd when send() fails. --- diff --git a/apps/examples/wifi_test/wifi_test.c b/apps/examples/wifi_test/wifi_test.c index 4f670d0..473aae6 100644 --- a/apps/examples/wifi_test/wifi_test.c +++ b/apps/examples/wifi_test/wifi_test.c @@ -204,15 +204,16 @@ int wifi_test_proc(int argc, char *argv[]) memset(payload, 0, BUF_MAX_SIZE); printScanResult(scan_info); - sprintf(payload, "/%s|", DEVICE_NAME); + snprintf(payload, BUF_MAX_SIZE, "/%s|", DEVICE_NAME); for (i = 0; i < aps_cnt; i++) { sprintf(buf, "%02d:%d/", g_aps[i].id, g_aps[i].rssi); - strcat(payload, buf); + strncat(payload, buf, strlen(buf)); } printf("[WiFi] PAYLOAD : %s\n", payload); if (sendto(fd, payload, strlen(payload), 0, (struct sockaddr *)&dest, sizeof(struct sockaddr_in)) == -1) { printf("[WiFi] Failed to sendto UDP.\n"); ret = -1; + closesocket(fd); goto error_out; } /* Type in code to free WiFi scan data. Do check and