robert@cheviot.uucp (Robert Stroud) (10/14/85)
Description:
Programs that follow the manual page inet(3n) will crash.
They won't even compile if you take the page literally!
Repeat-by:
Run this program on an IP address in your /etc/hosts file
# include <sys/types.h> /* NOT <sys/socket.h> !! */
# include <netinet/in.h>
# include <arpa/inet.h>
main(argc, argv)
int argc;
char *argv[];
{
struct in_addr addr;
addr = inet_addr(argv[1]);
}
Diagnosis:
Contrary to the manual page and the <arpa/inet.h> include file,
the routine "inet_addr" returns "u_long" rather than "struct in_addr".
The manual page almost admits this in the DIAGNOSTICS section
"The value -1 is returned by inet_addr for malformed requests"
Note that "-1" is not even a "u_long", let alone a "struct in_addr"!
Fix-by:
Alter the SYNOPSIS part of inet(3n) to read
# include <sys/types.h>
# include <netinet/in.h>
# include <arpa/inet.h>
long inet_addr(cp)
char *cp;
Fix <arpa/inet.h> and lib/libc/inet/inet_addr.c accordingly.
Robert Stroud,
Computing Laboratory,
University of Newcastle upon Tyne.
ARPA robert%cheviot.newcastle@ucl-cs.ARPA
UUCP ...!ukc!cheviot!robert