]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
lib/parser.c: avoid overflow in match_number()
authorAlex Elder <elder@inktank.com>
Thu, 13 Sep 2012 01:01:11 +0000 (11:01 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 13 Sep 2012 07:28:08 +0000 (17:28 +1000)
commit000d5f1d5b5bdc52700d6eb071aade7cbdef19a7
tree0ba71eb1fb255adef12b044463201a564d326590
parent704a55c2176d800956d57258cb34f80d5c9f98cc
lib/parser.c: avoid overflow in match_number()

The result of converting an integer value to another signed integer type
that's unable to represent the original value is implementation defined.
(See notes in section 6.3.1.3 of the C standard.)

In match_number(), the result of simple_strtol() (which returns type long)
is assigned to a value of type int.

Instead, handle the result of simple_strtol() in a well-defined way, and
return -ERANGE if the result won't fit in the int variable used to hold
the parsed result.

No current callers pay attention to the particular error value returned,
so this additional return code shouldn't do any harm.

Signed-off-by: Alex Elder <elder@inktank.com>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/parser.c