Fix ASAN build failure 33/235033/1 accepted/tizen/unified/20200608.043742 submit/tizen/20200602.065713 submit/tizen/20200607.221928
authorYu <jiung.yu@samsung.com>
Tue, 2 Jun 2020 01:33:21 +0000 (10:33 +0900)
committerYu <jiung.yu@samsung.com>
Tue, 2 Jun 2020 01:33:24 +0000 (10:33 +0900)
Change-Id: I991821c934ee8f2f401bc194f892a77a71c38a20
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c

index 1610df7..0463461 100644 (file)
@@ -349,7 +349,7 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
                                                temp[i+1] = (char) __ws_hex_to_num(ptr, 2);
                                                ptr += 2;
                                        }
-                                       strncat(query, temp, size + 1);
+                                       g_strlcat(query, temp, sizeof(query));
                                        g_free(temp);
                                        temp = NULL;
                                }
@@ -369,11 +369,11 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
                                ptr += 6;
                                if (dns_type == 12) {
                                        if (!strncmp(compr, "c011", 4))
-                                               strncat(query, ".local.", 7);
+                                               g_strlcat(query, ".local.", sizeof(query));
                                        else if (!strncmp(compr, "c00c", 4))
-                                               strncat(query, "._tcp.local.", 12);
+                                               g_strlcat(query, "._tcp.local.", sizeof(query));
                                        else if (!strncmp(compr, "c01c", 4))
-                                               strncat(query, "._udp.local.", 12);
+                                               g_strlcat(query, "._udp.local.", sizeof(query));
                                }
                        }
                }
@@ -392,7 +392,7 @@ static int __ws_segment_to_service(char *segment, wfd_oem_new_service_s **servic
                                                temp[i+1] = (char) __ws_hex_to_num(ptr, 2);
                                                ptr += 2;
                                        }
-                                       strncat(rdata, temp, size + 1);
+                                       g_strlcat(rdata, temp, sizeof(rdata));
                                        g_free(temp);
                                        temp = NULL;
                                }
@@ -3870,8 +3870,7 @@ static int __ws_check_net_interface(char* if_name)
        }
 
        memset(&ifr, 0, sizeof(ifr));
-       strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));
-       ifr.ifr_name[IFNAMSIZ-1] = '\0';
+       g_strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
 
        if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
                close(fd);
@@ -7703,15 +7702,15 @@ int ws_set_supported_wps_mode(int wps_mode)
        }
 
        if (new_wps_mode & WFD_OEM_WPS_MODE_KEYPAD) {
-               strncat(config_value, "keypad ", 7);
+               g_strlcat(config_value, "keypad ", sizeof(config_value));
                length += 7;
        }
        if (new_wps_mode & WFD_OEM_WPS_MODE_PBC) {
-               strncat(config_value, "virtual_push_button ", 20);
+               g_strlcat(config_value, "virtual_push_button ", sizeof(config_value));
                length += 20;
        }
        if (new_wps_mode & WFD_OEM_WPS_MODE_DISPLAY) {
-               strncat(config_value, "physical_display ", 17);
+               g_strlcat(config_value, "physical_display ", sizeof(config_value));
                length += 17;
        }
        config_value[length-1] = 0;