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