Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!hplabs!sri-unix!craig@SRN-VAX.ARPA From: craig@SRN-VAX.ARPA Newsgroups: net.unix-wizards Subject: Bug in inet(3N) library Message-ID: <12624@sri-arpa.UUCP> Date: Mon, 20-Aug-84 09:36:47 EDT Article-I.D.: sri-arpa.12624 Posted: Mon Aug 20 09:36:47 1984 Date-Received: Wed, 22-Aug-84 05:34:12 EDT Lines: 39 From: Craig PartridgeCompiled with -DDONTWORK (which produces a program conforming to what Berkeley tells you to do) the following program doesn't work. It gives the wrong answer on VAXen and core dumps on SUNs. --------------------------------------------- /* program to show a bug */ #include #include #include #ifdef DONTWORK #include #else extern char *inet_ntoa(); extern u_long inet_addr(); #endif main() { /* pretty sure the address used is not critical */ printf("%s\n",inet_ntoa(inet_addr("128.11.0.0"))); } __________________________________________________ Problem is that the compiler handles the structure in_addr, differently from a u_long, and while the include file declares inet_addr as a struct in_addr (a portable??? network address structure), in fact it returns a u_long. The different declarations produce different code, and the one for struct in_addr is wrong. The best solution is probably to just edit and redeclare inet_addr to be a u_long and forget this structure farce. Craig Partridge craig@bbn-unix {ihnp4,wjh12,{and others}}!bbncca!craig