New submission from Matt Robenolt:
This also affects socket.getaddrinfo on macOS only, but is fine on Linux. I've
not tested on Windows to see behavior there.
Given the IP address `0177.0000.0000.0001`, which is a valid octal format
representing `127.0.0.1`, we can see varying results. Confirmed in both python
2.7 and 3.5.
First, socket.gethostbyname is always wrong, and always returns `177.0.0.1`:
```
>>> socket.gethostbyname('0177.0000.0000.0001')
'177.0.0.1'
```
This can be seen on both Linux and macOS.
With `socket.getaddrinfo`, resolution is correct on Linux, but the bad
177.0.0.1 on macOS.
Linux:
```
>>> socket.getaddrinfo('0177.0000.0000.0001', None)[0]
(2, 1, 6, '', ('127.0.0.1', 0))
```
macOS:
```
>>> socket.getaddrinfo('0177.0000.0000.0001', None)[0]
(2, 2, 17, '', ('177.0.0.1', 0))
```
This behavior exists in both 2.7.12 and 3.5.2 at least. I haven't tested many
others, but I assume pretty universal.
----------
components: Library (Lib)
messages: 271237
nosy: mattrobenolt
priority: normal
severity: normal
status: open
title: socket.gethostbyname resolving octal IP addresses incorrectly
type: behavior
versions: Python 2.7, Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27612>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com