Fixed coverity issues 40/154340/1
authorhyunuktak <hyunuk.tak@samsung.com>
Tue, 10 Oct 2017 05:37:42 +0000 (14:37 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Tue, 10 Oct 2017 05:37:44 +0000 (14:37 +0900)
Change-Id: I19f27469c22bc1662c8a33afc92f3bebdc2c560d
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
src/helper/helper-nfacct-rule.c
src/monitor/stc-monitor.c

index aec0ef3..bd86b01 100755 (executable)
@@ -278,15 +278,15 @@ bool recreate_counter_by_name(char *cnt_name, nfacct_rule_s *cnt)
                iface = get_iftype_by_name(ifname_buf);
                /* check first part is it datacall */
                if (iface == STC_IFACE_DATACALL) {
-                       strncpy(cnt->ifname, ifname_buf, MAX_IFACE_LENGTH);
+                       strncpy(cnt->ifname, ifname_buf, MAX_IFACE_LENGTH - 1);
                        cnt->iotype = NFACCT_COUNTER_IN;
                } else {
                        /* +1, due : symbol and till the end of cnt_name */
-                       strncpy(ifname_buf, iftype_part + 1, MAX_IFACE_LENGTH);
+                       strncpy(ifname_buf, iftype_part + 1, MAX_IFACE_LENGTH - 1);
                        iface = get_iftype_by_name(ifname_buf);
                        if (iface == STC_IFACE_DATACALL) {
                                cnt->iotype = NFACCT_COUNTER_OUT;
-                               strncpy(cnt->ifname, ifname_buf, MAX_IFACE_LENGTH);
+                               strncpy(cnt->ifname, ifname_buf, MAX_IFACE_LENGTH - 1);
                        }
                }
 
index a50d65b..522a615 100755 (executable)
@@ -716,7 +716,7 @@ static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system)
 
        /* create netlink socket for updating kernel counters */
        system->contr_sock = create_netlink(NETLINK_NETFILTER, 0);
-       if (!(system->contr_sock)) {
+       if (system->contr_sock < 0) {
                STC_LOGE("failed to open socket");
                FREE(system);
                return STC_ERROR_FAIL;
@@ -1599,7 +1599,7 @@ stc_error_e stc_monitor_init(void)
 
        /* create netlink socket for updating kernel counters */
        system->contr_sock = create_netlink(NETLINK_NETFILTER, 0);
-       if (!(system->contr_sock)) {
+       if (system->contr_sock < 0) {
                STC_LOGE("failed to open socket");
                FREE(system);
                return STC_ERROR_FAIL;