From 8be02456649f5a26771f70754659fafd5039efe9 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 28 Jul 2015 10:18:26 -0500 Subject: [PATCH] cdma-connman: 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. 92 strncpy(ifr.ifr_name, interface, IFNAMSIZ); --- src/cdma-connman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cdma-connman.c b/src/cdma-connman.c index 2f2ea54d..cd2a6f76 100644 --- a/src/cdma-connman.c +++ b/src/cdma-connman.c @@ -89,7 +89,7 @@ static void cdma_connman_ifupdown(const char *interface, ofono_bool_t active) return; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, interface, IFNAMSIZ); + strncpy(ifr.ifr_name, interface, IFNAMSIZ - 1); if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) goto done;