From 1b98cdb0514151d72ffb4345dd7864e22fc7db91 Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Mon, 1 Apr 2019 10:30:41 +0200 Subject: [PATCH] Update int-parsing.md --- notes/dominik.czarnota/int-parsing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notes/dominik.czarnota/int-parsing.md b/notes/dominik.czarnota/int-parsing.md index b02364a3..7ecf7538 100644 --- a/notes/dominik.czarnota/int-parsing.md +++ b/notes/dominik.czarnota/int-parsing.md @@ -86,6 +86,8 @@ TODO: analyze them ### Atoi converted to int32/int64 +**Since `Atoi` returns an `int` - casting to `int64` is rather fine. Casting to `int32` may overflow and the cast is needed - but to be valid, they should rather use `strconv.ParseInt` with `bits=32`.** + There are places where they convert string to int and then convert it to appropriate type. The value itself may be overflowed and the error won't be detected in those cases. In `src/kubernetes-1.13.4/pkg/cloudprovider/providers/aws/aws.go:3169`: @@ -506,4 +508,4 @@ func (s *SecureServingInfo) HostPort() (string, int, error) { } return host, port, nil } -``` \ No newline at end of file +```