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

NetUtil.bytesToIpAddress broken for IPv4 #5821

Closed
henrik-lindqvist opened this issue Sep 14, 2016 · 3 comments
Closed

NetUtil.bytesToIpAddress broken for IPv4 #5821

henrik-lindqvist opened this issue Sep 14, 2016 · 3 comments
Assignees
Labels

Comments

@henrik-lindqvist
Copy link

For textual IPv4 representation the method incorrectly performs bit shifts on the array bytes.

4.1.5.Final

@normanmaurer
Copy link
Member

@henrik-lindqvist maybe you can provide a PR ?

@Scottmitch
Copy link
Member

or provide a link to an RFC or specification which describes expected behavior and an input which doesn't produce the expected output.

@henrik-lindqvist
Copy link
Author

NetUtil.bytesToIpAddress(new byte[] { 83, -1, -20, 16 }, 0, 4) returns "0.255.255.16" not "83.255.236.16" as expected. See initial post for cause.

@Scottmitch Scottmitch self-assigned this Sep 15, 2016
Scottmitch added a commit to Scottmitch/netty that referenced this issue Sep 22, 2016
Motivation:
NetUtil.bytesToIpAddress does not correctly translate IPv4 address to String. Also IPv6 addresses may not follow minimization conventions when converting to a String (see rfc 5952).

Modifications:
- NetUtil.bytesToIpAddress should correctly handle negative byte values for IPv4
- NetUtil.bytesToIpAddress should leverage existing to string conversion code in NetUtil

Result:
Fixes netty#5821
liuzhengyang pushed a commit to liuzhengyang/netty that referenced this issue Sep 10, 2017
Motivation:
NetUtil.bytesToIpAddress does not correctly translate IPv4 address to String. Also IPv6 addresses may not follow minimization conventions when converting to a String (see rfc 5952).

Modifications:
- NetUtil.bytesToIpAddress should correctly handle negative byte values for IPv4
- NetUtil.bytesToIpAddress should leverage existing to string conversion code in NetUtil

Result:
Fixes netty#5821
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants