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);
}
}
/* 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;
/* 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;