OSDN Git Service

android/pan: Fix not NULL terminating parsed string
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 29 Jul 2015 06:24:48 +0000 (15:24 +0900)
committerSzymon Janc <szymon.janc@tieto.com>
Wed, 29 Jul 2015 07:26:00 +0000 (09:26 +0200)
This patch prevents the possible not NULL terminating problem.
ifr_name's array size is IFNAMSIZ. So If BNEP_BRIDGE has IFNAMSIZ size,
the name string will be not NULL terminating.

android/pan.c

index 0bb576e..c40a6d3 100644 (file)
@@ -88,7 +88,7 @@ static int set_forward_delay(int sk)
        struct ifreq ifr;
 
        memset(&ifr, 0, sizeof(ifr));
-       strncpy(ifr.ifr_name, BNEP_BRIDGE, IFNAMSIZ);
+       strncpy(ifr.ifr_name, BNEP_BRIDGE, IFNAMSIZ - 1);
        ifr.ifr_data = (char *) args;
 
        if (ioctl(sk, SIOCDEVPRIVATE, &ifr) < 0) {