]> git.karo-electronics.de Git - karo-tx-linux.git/commit
lib/parser.c: avoid overflow in match_number()
authorAlex Elder <elder@inktank.com>
Fri, 28 Sep 2012 00:20:24 +0000 (10:20 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 5 Oct 2012 04:01:25 +0000 (14:01 +1000)
commitb703da5742d03c17ed675243287b06a249edc75e
tree3b07d0cdb5e574520cc41e1b032854ae087312bc
parent3fb777fed4e6efa49f4287bafa5966ebd6cca60f
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