From: Denis Kenzior Date: Tue, 28 Jul 2015 15:16:16 +0000 (-0500) Subject: ppp_net: Make static analysis tools happy X-Git-Tag: upstream/1.17~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca105f704051604053b4c5f6895284733cb10a0b;p=platform%2Fupstream%2Fofono.git ppp_net: Make static analysis tools happy The kernel simply puts a null terminator at index 15 prior to ifr_name processing. So we do the same. Original report by: Sabas Rosales, Blanca E Buffer not null terminated (BUFFER_SIZE_WARNING) buffer_size_warning: Calling strncpy with a maximum size argument of 16 bytes on destination array ifr.ifr_ifrn.ifrn_name of size 16 bytes might leave the destination string unterminated. 67 strncpy(ifr.ifr_name, net->if_name, sizeof(ifr.ifr_name)); --- diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index 914ca537..b35dcd17 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -64,7 +64,7 @@ gboolean ppp_net_set_mtu(struct ppp_net *net, guint16 mtu) return FALSE; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, net->if_name, sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name, net->if_name, IFNAMSIZ - 1); ifr.ifr_mtu = mtu; err = ioctl(sk, SIOCSIFMTU, (void *) &ifr);