From f1da4a9a4b4a91c49d1f1c159f72379f917fe74b Mon Sep 17 00:00:00 2001 From: John Kohl Date: Fri, 19 Apr 1991 16:21:21 +0000 Subject: [PATCH] use MAXHOSTNAMELEN git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2016 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/simple/client/sim_client.c | 9 ++++++++- src/appl/simple/server/sim_server.c | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/appl/simple/client/sim_client.c b/src/appl/simple/client/sim_client.c index 4430940ec..d3b1eb86f 100644 --- a/src/appl/simple/client/sim_client.c +++ b/src/appl/simple/client/sim_client.c @@ -28,10 +28,16 @@ static char rcsid_sim_client_c[] = #include #include #include +#include #include #include "simple.h" +/* for old Unixes and friends ... */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + #define MSG "hi there!" /* message text */ #define PROGNAME argv[0] @@ -47,7 +53,7 @@ char *argv[]; struct servent *serv; struct hostent *host; char *cp; - char full_hname[256]; /* XXX magic number */ + char full_hname[MAXHOSTNAMELEN]; struct sockaddr_in s_sock; /* server address */ struct sockaddr_in c_sock; /* client address */ @@ -88,6 +94,7 @@ char *argv[]; exit(1); } strncpy(full_hname, host->h_name, sizeof(full_hname)-1); + full_hname[sizeof(full_hname)-1] = '\0'; /* lower-case to get name for "instance" part of service name */ for (cp = full_hname; *cp; cp++) diff --git a/src/appl/simple/server/sim_server.c b/src/appl/simple/server/sim_server.c index aefcf6e95..f4c67bffc 100644 --- a/src/appl/simple/server/sim_server.c +++ b/src/appl/simple/server/sim_server.c @@ -29,10 +29,16 @@ static char rcsid_sim_server_c [] = #include #include #include +#include #include #include "simple.h" +/* for old Unixes and friends ... */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + #define PROGNAME argv[0] #define SNAME argv[1] @@ -47,7 +53,7 @@ char *argv[]; struct hostent *host; struct sockaddr_in s_sock; /* server's address */ struct sockaddr_in c_sock; /* client's address */ - char full_hname[256]; /* XXX magic number; for hostname */ + char full_hname[MAXHOSTNAMELEN]; char *cp; krb5_error_code retval; -- 2.26.2