isdnloop: Validate NUL-terminated strings from user.
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Wed, 2 Apr 2014 03:48:42 +0000 (12:48 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Apr 2014 13:42:18 +0000 (06:42 -0700)
[ Upstream commit 77bc6bed7121936bb2e019a8c336075f4c8eef62 ]

Return -EINVAL unless all of user-given strings are correctly
NUL-terminated.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/isdn/isdnloop/isdnloop.c

index 02125e6..e1f8748 100644 (file)
@@ -1070,6 +1070,12 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
                return -EBUSY;
        if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
                return -EFAULT;
+
+       for (i = 0; i < 3; i++) {
+               if (!memchr(sdef.num[i], 0, sizeof(sdef.num[i])))
+                       return -EINVAL;
+       }
+
        spin_lock_irqsave(&card->isdnloop_lock, flags);
        switch (sdef.ptype) {
        case ISDN_PTYPE_EURO: