]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
I4L: fix isdn_ioctl memory overrun vulnerability (CVE-2007-6151)
authorKarsten Keil <kkeil@suse.de>
Sun, 20 Jan 2008 22:10:25 +0000 (00:10 +0200)
committerAdrian Bunk <bunk@kernel.org>
Mon, 21 Jan 2008 00:14:20 +0000 (02:14 +0200)
Fix possible memory overrun issue in the isdn ioctl code.

Found by ADLAB <adlab@venustech.com.cn>

Signed-off-by: Karsten Keil <kkeil@suse.de>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
drivers/isdn/i4l/isdn_common.c

index 4cd1a5a0b7103a7fe70b727080882ede187daf19..93444978a07e91d829c1fa186f451c1dd696bd8b 100644 (file)
@@ -1506,6 +1506,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        if (copy_from_user(&iocts, argp,
                                             sizeof(isdn_ioctl_struct)))
                                                return -EFAULT;
+                                       iocts.drvid[sizeof(iocts.drvid)-1] = 0;
                                        if (strlen(iocts.drvid)) {
                                                if ((p = strchr(iocts.drvid, ',')))
                                                        *p = 0;
@@ -1590,6 +1591,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        if (copy_from_user(&iocts, argp,
                                             sizeof(isdn_ioctl_struct)))
                                                return -EFAULT;
+                                       iocts.drvid[sizeof(iocts.drvid)-1] = 0;
                                        if (strlen(iocts.drvid)) {
                                                drvidx = -1;
                                                for (i = 0; i < ISDN_MAX_DRIVERS; i++)
@@ -1634,7 +1636,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        } else {
                                                p = (char __user *) iocts.arg;
                                                for (i = 0; i < 10; i++) {
-                                                       sprintf(bname, "%s%s",
+                                                       snprintf(bname, sizeof(bname), "%s%s",
                                                                strlen(dev->drv[drvidx]->msn2eaz[i]) ?
                                                                dev->drv[drvidx]->msn2eaz[i] : "_",
                                                                (i < 9) ? "," : "\0");
@@ -1664,6 +1666,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        char *p;
                                        if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct)))
                                                return -EFAULT;
+                                       iocts.drvid[sizeof(iocts.drvid)-1] = 0;
                                        if (strlen(iocts.drvid)) {
                                                if ((p = strchr(iocts.drvid, ',')))
                                                        *p = 0;