2008-06-26 Dan Williams <dcbw@redhat.com>

Patch from David Cantrell <dcantrell@redhat.com>
	
	* Use inet_ntop() and inet_pton() everwhere and check for errors



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3777 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2008-06-26 19:33:13 +00:00
parent 518095511e
commit dd0109ee28
17 changed files with 162 additions and 46 deletions

View File

@@ -106,6 +106,9 @@ void nm_system_activate_nis (NMIP4Config *config)
struct in_addr temp_addr;
int i;
FILE *ypconf = NULL;
char buf[INET_ADDRSTRLEN+1];
memset (&buf, '\0', sizeof (buf));
g_return_if_fail (config != NULL);
@@ -145,7 +148,12 @@ void nm_system_activate_nis (NMIP4Config *config)
fprintf (ypconf, "# generated by NetworkManager, do not edit!\n\n");
for (i = 0; i < num_nis_servers; i++) {
temp_addr.s_addr = nm_ip4_config_get_nis_server (config, i);
fprintf (ypconf, "domain %s server %s\n", nis_domain, inet_ntoa (temp_addr));
if (!inet_ntop (AF_INET, &temp_addr, buf, INET_ADDRSTRLEN))
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (tempaddr.s_addr));
else
fprintf (ypconf, "domain %s server %s\n", nis_domain, buf);
}
fprintf (ypconf, "\n");
fclose (ypconf);