Use inet_pton() instead of inet_aton() and include a version from

BIND for those without it.
This commit is contained in:
Todd C. Miller
2014-02-05 10:00:07 -07:00
parent 91141e5cc1
commit 85598f77b2
11 changed files with 314 additions and 100 deletions

View File

@@ -65,7 +65,7 @@ addr_matches_if(const char *n)
family = AF_INET6;
} else
#endif /* HAVE_STRUCT_IN6_ADDR */
if (inet_aton(n, &addr.ip4) == 1) {
if (inet_pton(AF_INET, n, &addr.ip4) == 1) {
family = AF_INET;
} else {
debug_return_bool(false);
@@ -118,7 +118,7 @@ addr_matches_if_netmask(const char *n, const char *m)
family = AF_INET6;
else
#endif /* HAVE_STRUCT_IN6_ADDR */
if (inet_aton(n, &addr.ip4) == 1) {
if (inet_pton(AF_INET, n, &addr.ip4) == 1) {
family = AF_INET;
} else {
debug_return_bool(false);
@@ -126,7 +126,7 @@ addr_matches_if_netmask(const char *n, const char *m)
if (family == AF_INET) {
if (strchr(m, '.')) {
if (inet_aton(m, &mask.ip4) != 1) {
if (inet_pton(AF_INET, m, &mask.ip4) != 1) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"IPv4 netmask %s: %s", m, "invalid value");
debug_return_bool(false);