]> git.karo-electronics.de Git - karo-tx-linux.git/commit
lib/parser.c: avoid overflow in match_number()
authorAlex Elder <elder@inktank.com>
Wed, 26 Sep 2012 01:34:27 +0000 (11:34 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 27 Sep 2012 07:27:55 +0000 (17:27 +1000)
commit660fd23907789d9dd09dc940d0558a8a1f22e2ff
tree5273dfd5aa3bfab5786ddcfef359eacc4649bd5e
parent4613e5e55cf663b3748b10142a94b5a7c66f686f
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