Use sudo_strsplit() in dump_interfaces.

This commit is contained in:
Todd C. Miller
2015-06-19 08:57:54 -06:00
parent 4f9cabd005
commit 69a4af9e7b

View File

@@ -111,18 +111,17 @@ get_interfaces(void)
void void
dump_interfaces(const char *ai) dump_interfaces(const char *ai)
{ {
char *cp, *addrinfo; const char *cp, *ep;
const char *ai_end = ai + strlen(ai);
debug_decl(set_interfaces, SUDOERS_DEBUG_NETIF) debug_decl(set_interfaces, SUDOERS_DEBUG_NETIF)
if ((addrinfo = strdup(ai)) == NULL) { sudo_printf(SUDO_CONV_INFO_MSG,
sudo_warnx(U_("unable to allocate memory")); _("Local IP address and netmask pairs:\n"));
} else { cp = sudo_strsplit(ai, ai_end, " \t", &ep);
sudo_printf(SUDO_CONV_INFO_MSG, while (cp != NULL) {
_("Local IP address and netmask pairs:\n")); sudo_printf(SUDO_CONV_INFO_MSG, "\t%.*s\n", (int)(ep - cp), cp);
for (cp = strtok(addrinfo, " \t"); cp != NULL; cp = strtok(NULL, " \t")) cp = sudo_strsplit(NULL, ai_end, " \t", &ep);
sudo_printf(SUDO_CONV_INFO_MSG, "\t%s\n", cp);
free(addrinfo);
} }
debug_return; debug_return;
} }