jordan@ucbarpa.Berkeley.EDU (Jordan Hayes) (08/31/86)
The 4.3 (and, I assume, moving backwards from there to 4.2, since I looked at the SCCS info for it and it hasn't seen much re-write, mostly little fixes) lib/libc/net/getnetent.c doesn't seem to do the right thing. You can repeat it by writing a little program to try to get each network entry and print it out ... I had problems with lines that have neither an alias nor a comment right after a line that has both, but I didn't do real extensive testing. The code looked pretty obscure, so I re-wrote the routine. If you want a copy, drop me a note. I assume that no one really uses this code very much, since it could just be untested. Here's the program I used to find the bug: ----- #include <stdio.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> main() { register char **cp; struct netent *np; setnetent(1); while ((np = getnetent()) != (struct netent *)NULL) { printf("name\t%s\n", np->n_name); for (cp = np->n_aliases; cp && *cp && **cp; cp++) printf("alias\t%s\n", *cp); printf("addr\t%s\n\n", inet_ntoa(htonl(np->n_net))); } } ----- /jordan