[11264] in Athena Bugs
Re: decmips 7.6G: hostinfo
daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Sat Oct 23 12:29:38 1993
From: epeisach@MIT.EDU
Date: Sat, 23 Oct 93 12:29:19 -0400
To: bugs@MIT.EDU
Cc: tom@MIT.EDU
The problem was that in gethostnamadr.c the gethinfobyname used a
querybuf which then returned to the calling user a pointer to the
automatic buffer which was being corrupted. The addition of the keyword
'static' solves the problem.
While I was at it, I fixed some other 'misfeatures' like including
string.h so that the return type of strlen was known, some prototypes,
and other SABER warnings.
I did not fix the code where 'hostinfo -s' does something useful....
Ezra
RCS file: RCS/gethostnamadr.c,v
retrieving revision 1.1
diff -c -r1.1 gethostnamadr.c
*** /tmp/,RCSt1a05731 Sat Oct 23 12:22:51 1993
--- gethostnamadr.c Sat Oct 23 12:14:14 1993
***************
*** 37,42 ****
--- 37,43 ----
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <resolv.h>
+ #include <string.h>
#define MAXALIASES 35
#define MAXADDRS 35
***************
*** 246,252 ****
register char *cp;
int n;
extern struct hostent *_gethtbyname();
- char *d;
/*
* disallow names consisting only of digits/dots, unless
--- 247,252 ----
***************
*** 324,330 ****
gethinfobyname(name)
char *name;
{
! querybuf buf;
register char *cp;
int n;
extern struct hostent *_gethtbyname();
--- 324,330 ----
gethinfobyname(name)
char *name;
{
! static querybuf buf;
register char *cp;
int n;
extern struct hostent *_gethtbyname();
***************
*** 367,373 ****
getmxbyname(name)
char *name;
{
! querybuf buf;
register char *cp;
int n;
extern struct hostent *_gethtbyname();
--- 367,373 ----
getmxbyname(name)
char *name;
{
! static querybuf buf;
register char *cp;
int n;
extern struct hostent *_gethtbyname();
===================================================================
RCS file: RCS/hostinfo.c,v
retrieving revision 1.1
diff -c -r1.1 hostinfo.c
*** /tmp/,RCSt1a05731 Sat Oct 23 12:22:52 1993
--- hostinfo.c Sat Oct 23 12:18:03 1993
***************
*** 21,27 ****
*
*/
! #ifndef lint
static char rcsid[] = "$Header: /paris/u2/lockers/epeisach/hostinfo/RCS/hostinfo.c,v 1.1 93/10/23 11:56:33 epeisach Exp Locker: epeisach $";
#endif
--- 21,27 ----
*
*/
! #if !defined(lint) && !defined(SABER)
static char rcsid[] = "$Header: /paris/u2/lockers/epeisach/hostinfo/RCS/hostinfo.c,v 1.1 93/10/23 11:56:33 epeisach Exp Locker: epeisach $";
#endif
***************
*** 32,37 ****
--- 32,38 ----
#include <strings.h> /* String fct. declarations. */
#include <ctype.h> /* Character type macros. */
#include <netinet/in.h> /* Internet defs. */
+ #include <arpa/inet.h> /* For inet_addr */
typedef int bool;
***************
*** 41,46 ****
--- 42,50 ----
#define ERROR -1
#define CPNULL ((char *) NULL)
+ extern char *gethinfobyname(), *getmxbyname();
+
+
static char *usage[] = {
"Usage: %s <options> <host-names-or-addresses>",
" -h: output only hostname",
***************
*** 149,155 ****
}
}
! if(host_entry <= 0)
{
host_entry = gethostbyname(hostname);
if(host_entry)
--- 153,159 ----
}
}
! if(host_entry == NULL)
{
host_entry = gethostbyname(hostname);
if(host_entry)