Article View: net.bugs.4bsd
Article #1655problems with getnetent()
From: Jordan Hayes
Date: Sat, 30 Aug 1986 22:32
Date: Sat, 30 Aug 1986 22:32
37 lines
1772 bytes
1772 bytes
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
Technical Details
Message-ID:
<15478@ucbvax.BERKELEY.EDU>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!columbia!caip!clyde!cbatt!cbosgd!ucbvax!ucbarpa.Berkeley.EDU!jordanShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!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