Staging: most: fix snprintf() is printing too much
authorChristian Gromm <christian.gromm@microchip.com>
Tue, 28 Jul 2015 15:16:09 +0000 (17:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2015 20:43:15 +0000 (13:43 -0700)
This patch prevents snprintf from exceeding a given buffer size.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/mostcore/core.c

index 98a4c90..49d03af 100644 (file)
@@ -983,7 +983,7 @@ static ssize_t store_add_link(struct most_aim_obj *aim_obj,
                return ret;
 
        if (mdev_devnod == 0 || *mdev_devnod == 0) {
-               snprintf(devnod_buf, PAGE_SIZE, "%s-%s", mdev, mdev_ch);
+               snprintf(devnod_buf, sizeof(devnod_buf), "%s-%s", mdev, mdev_ch);
                mdev_devnod = devnod_buf;
        }