Date: Fri, 9 Aug 2002 14:24:22 -0400 From: Antoine Beaupre <anarcat@anarcat.ath.cx> To: freebsd-arch@freebsd.org Subject: implementation differences between inet_aton() and inet_pton() Message-ID: <3A565436-ABC5-11D6-BAC6-0050E4A0BB3F@anarcat.ath.cx>
next in thread | raw e-mail | index | archive | help
Hi I just stumbled upon some differences between the results given by inet_aton() and inet_pton(). inet_aton() converts substrings to numbers using strtoul(). This means that an address like "127.0x0.0.01" will be parsed as "127.0.0.1". On the other hand, inet_pton() parses the number directly, using a clever hack: u_int new = *tp * 10 + (pch - digits); This assumes the number is in base 10. This means that an address like "127.0x0.0.01" will result in a parse error. (more precisely: 0 if the address wasn't parseable in the specified address family). Is this difference there by design or accident? In either case it should be documented how each function parses the numbers, because it is rather important. A. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A565436-ABC5-11D6-BAC6-0050E4A0BB3F>