Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!caip!clyde!cbatt!cbosgd!ucbvax!ucbarpa.Berkeley.EDU!jordan From: jordan@ucbarpa.Berkeley.EDU (Jordan Hayes) Newsgroups: net.bugs.4bsd Subject: problems with getnetent() Message-ID: <15478@ucbvax.BERKELEY.EDU> Date: Sat, 30-Aug-86 18:32:12 EDT Article-I.D.: ucbvax.15478 Posted: Sat Aug 30 18:32:12 1986 Date-Received: Sun, 31-Aug-86 09:04:13 EDT Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: jordan@ucbarpa.Berkeley.EDU (Jordan Hayes) Organization: University of California, Berkeley Lines: 37 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 #include #include #include #include #include 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