From 660a6825eabcf8529826e25052a8546ac8e1f08f Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 4 May 2015 11:28:51 -0700 Subject: fmt: catch overflow in width and prec calculations Fixes #10674. Change-Id: If3fae3244d87aeaa70815f499105c264394aa7ad Reviewed-on: https://go-review.googlesource.com/9657 Reviewed-by: Ian Lance Taylor --- src/fmt/print.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/fmt/print.go') diff --git a/src/fmt/print.go b/src/fmt/print.go index 8e35a890ec..9c373145dd 100644 --- a/src/fmt/print.go +++ b/src/fmt/print.go @@ -292,6 +292,9 @@ func parsenum(s string, start, end int) (num int, isnum bool, newi int) { } for newi = start; newi < end && '0' <= s[newi] && s[newi] <= '9'; newi++ { num = num*10 + int(s[newi]-'0') + if num < 0 { + return 0, false, end // Overflow; crazy long number most likely. + } isnum = true } return -- cgit v1.2.1