lib/kstrtox.c Stop parsing integer on overflow
PATCH 1/1 lib/kstrtox.c Stop parsing integer on overflow
From: Anshul Garg <[email protected]>
While converting string representation to integer
break the loop if overflow is detected.
--- lib/kstrtox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/kstrtox.c +3 -1
@@ -70,8 +70,10 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long* it in the max base we support (16) */ if (unlikely (res & (~0ull <<60 ))) { -if (res >div_u64 (ULLONG_MAX - val, base)) +if (res >div_u64 (ULLONG_MAX - val, base)) { overflow =1 ; +break ; + } } res = res * base + val; rv++;
Signature · 6 lines
1.7.9.5 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
Quoted 15 lines · Anshul Garg
From: Anshul Garg <[email protected]>
While converting string representation to integer
break the loop if overflow is detected.Signed-off-by Anshul Garg <[email protected]>--- lib/kstrtox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/kstrtox.c +0
-0
lib/kstrtox.c unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long · line 75
Quoted 7 lines
lib/kstrtox.c +2
-1@@ -70,8 +70,10 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long* it in the max base we support (16) */ if (unlikely (res & (~0ull <<60 ))) { -if (res >div_u64 (ULLONG_MAX - val, base)) +if (res >div_u64 (ULLONG_MAX - val, base)) { overflow =1 ; +break ;
This changes the behaviour as described at the function description. Did you double check that all users of that function can deal with that?
Quoted 17 lines
lib/kstrtox.c +1
-1+ } } res = res * base + val; rv++; --1.7.9.5
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
Thanks, //richard