lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Wed, 2 Aug 2006 23:36:30 +0200
From:	Magnus Vigerlöf <wigge@...foot.com>
To:	linux-input@...ey.karlin.mff.cuni.cz
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] input: Null-termination of strings returned to userspace

Removes the risk of returning non-null terminated strings
to userspace in those cases the provided buffer is too small.

Signed-off-by: Magnus Vigerlöf <wigge@...foot.com>
---
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 12c7ab8..667333c 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -377,11 +377,13 @@ static int str_to_user(const char *str, 
 	if (!str)
 		return -ENOENT;
 
-	len = strlen(str) + 1;
-	if (len > maxlen)
-		len = maxlen;
+	len = strlen(str);
+	if (len >= maxlen)
+		len = maxlen - 1;
 
-	return copy_to_user(p, str, len) ? -EFAULT : len;
+	if (copy_to_user(p, str, len))
+		return -EFAULT;
+	return put_user('\0', (char __user *)p + len) ? -EFAULT : len + 1;
 }
 
 static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ