This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi! If all of networking is shut up before some daemon dies and that daemon then calls pmap_unset, kernel complains: forgot to set AF_INET in udp sendmsg The issue is that if __get_myaddress does not find any address, it simply leaves garbage in myaddress without letting the caller know, so it then calls clntudp_bufcreate on it. get_myaddress has similar issue, but unlike __get_myaddress it is exported, so its prototype obviously cannot be changed. Would it make sense to put something like addr->sin_family = AF_INET; addr->sin_port = htons (PMAPPORT); addr->sin_addr.s_addr = htonl (INADDR_LOOPBACK); __bzero (addr->sin_zero, sizeof (addr->sin_zero)); at the end of get_myaddress (it is IMHO better than leave there garbage, or is get_myaddress caller required to initialize sockaddr_in before it passes it to get_myaddress)? 2001-01-04 Jakub Jelinek <jakub@redhat.com> * sunrpc/pmap_clnt.c (__get_myaddress): Return TRUE if successful, FALSE otherwise. (pmap_set, pmap_unset): Check __get_myaddress return value. --- libc/sunrpc/pmap_clnt.c.jj Sat Jun 19 11:47:40 1999 +++ libc/sunrpc/pmap_clnt.c Thu Jan 4 17:26:52 2001 @@ -51,7 +51,7 @@ * interface. portmap caches interfaces, and on DHCP clients, * it could be that only loopback is started at this time. */ -static void +static bool_t __get_myaddress (struct sockaddr_in *addr) { int s; @@ -89,7 +89,7 @@ __get_myaddress (struct sockaddr_in *add *addr = *((struct sockaddr_in *) &ifr->ifr_addr); addr->sin_port = htons (PMAPPORT); __close (s); - return; + return TRUE; } ifr++; } @@ -99,6 +99,7 @@ __get_myaddress (struct sockaddr_in *add goto again; } __close (s); + return FALSE; } @@ -118,7 +119,8 @@ pmap_set (u_long program, u_long version struct pmap parms; bool_t rslt; - __get_myaddress (&myaddress); + if (!__get_myaddress (&myaddress)) + return FALSE; client = clntudp_bufcreate (&myaddress, PMAPPROG, PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); if (client == (CLIENT *) NULL) @@ -152,7 +154,8 @@ pmap_unset (u_long program, u_long versi struct pmap parms; bool_t rslt; - __get_myaddress (&myaddress); + if (!__get_myaddress (&myaddress)) + return FALSE; client = clntudp_bufcreate (&myaddress, PMAPPROG, PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); if (client == (CLIENT *) NULL) Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |