sysctl: fix null checking in bin_dn_node_address()

commit df1778be1a upstream.

The null check of `strchr() + 1' is broken, which is always non-null,
leading to OOB read.  Instead, check the result of strchr().

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Xi Wang 2013-02-27 17:05:21 -08:00 committed by Greg Kroah-Hartman
parent ef7a6c3440
commit d48e3a8dc4
1 changed files with 2 additions and 1 deletions

View File

@ -1194,9 +1194,10 @@ static ssize_t bin_dn_node_address(struct file *file,
/* Convert the decnet address to binary */
result = -EIO;
nodep = strchr(buf, '.') + 1;
nodep = strchr(buf, '.');
if (!nodep)
goto out;
++nodep;
area = simple_strtoul(buf, NULL, 10);
node = simple_strtoul(nodep, NULL, 10);