4 ms·
No need to guess. My man page for inet_aton says it comes from 4.3BSD: https://github.com/dank101/4.3BSD-Reno/blob/master/lib/libc/net/inet_addr.c https://githu
by wahern 3y ago
No need to guess. My man page for inet_aton says it comes from 4.3BSD: https://github.com/dank101/4.3BSD-Reno/blob/master/lib/libc/net/inet_addr.c https://github.com/dank101/4.3BSD-Reno/blob/master/lib/libc/...
The earlier inet_addr from 4.2BSD has the same logic: https://github.com/dank101/4.2BSD/blob/master/lib/libc/inet/inet_addr.c https://github.com/dank101/4.2BSD/blob/master/lib/libc/inet/...
inet_aton and inet_addr parse addresses the obvious way. Using something like strtoul or especially sscanf would be stilted. The beauty of C pointers is that it makes simple parsing tasks very easy--perhaps too easy.
- Joker_vD 3y agoO_O They've intentionally coded it that way? This is atrocious. And this hand-rolled mess that doesn't even parse numbers correctly! It would parse "099" as 81 and "99999999999999999" as whatever it is modulo (MAX_ULONG+1), without any overflow detection. Well, at least they don't accept negative numbers, that's something. Anf mind you, beauty of C pointers has nothing to do with neither of these two bugs not the original decision to support octals and hexadecimals.