The Wayback Machine - https://web.archive.org/web/20210811021802/https://github.com/douyu/jupiter/issues/242
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Incorrect conversion between integer types #242

Open
hnlq715 opened this issue Aug 11, 2021 · 0 comments
Open

[BUG] Incorrect conversion between integer types #242

hnlq715 opened this issue Aug 11, 2021 · 0 comments

Comments

@hnlq715
Copy link
Member

@hnlq715 hnlq715 commented Aug 11, 2021

Issue Description

Type: bug report

Describe what happened

port, err := strconv.Atoi(portStr)

binary.BigEndian.PutUint16(buf, uint16(port))

If a string is parsed into an int using strconv.Atoi, and subsequently that int is converted into another integer type of a smaller size, the result can produce unexpected values.

Describe what you expected to happen

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

What version of Go are you using (go version)?

$ go version

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

Anything else we need to know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant