[S390] sclp_async: potential buffer overflow
authorDan Carpenter <[email protected]>
Fri, 9 Apr 2010 11:42:59 +0000 (13:42 +0200)
committerMartin Schwidefsky <[email protected]>
Fri, 9 Apr 2010 11:43:02 +0000 (13:43 +0200)
"len" hasn't been properly range checked so we shouldn't use it as an
array offset.  This can only be written to by root but it would still be
annoying to accidentally write more than 3 characters and corrupt your
memory.

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Martin Schwidefsky <[email protected]>
drivers/s390/char/sclp_async.c

index 2aecf7f21361b9d430b531e9b6697a8515a84923..7ad30e72f868de1e45ef7e4bdd81cfa8a4701ca4 100644 (file)
@@ -85,7 +85,7 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,
                rc = copy_from_user(buf, buffer, sizeof(buf));
                if (rc != 0)
                        return -EFAULT;
-               buf[len - 1] = '\0';
+               buf[sizeof(buf) - 1] = '\0';
                if (strict_strtoul(buf, 0, &val) != 0)
                        return -EINVAL;
                if (val != 0 && val != 1)