From 5e5b36eeda5d8b4e433ef84562dade2c980b0429 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Tue, 29 Oct 1996 11:32:21 +0000 Subject: [PATCH] save copies of addresses that otherwise get overwritten. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@914 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/popper/pop_init.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/appl/popper/pop_init.c b/appl/popper/pop_init.c index b4cdbe525..cd16dd822 100644 --- a/appl/popper/pop_init.c +++ b/appl/popper/pop_init.c @@ -151,7 +151,8 @@ pop_init(POP *p,int argcount,char **argmessage) /* Save the dotted decimal form of the client's IP address in the POP parameter block */ - p->ipaddr = inet_ntoa(cs.sin_addr); + strncpy (p->ipaddr, inet_ntoa(cs.sin_addr), sizeof(p->ipaddr)); + p->ipaddr[sizeof(p->ipaddr) - 1] = '\0'; /* Save the client's port */ p->ipport = ntohs(cs.sin_port); @@ -161,7 +162,7 @@ pop_init(POP *p,int argcount,char **argmessage) if (ch == NULL){ pop_log(p,POP_PRIORITY, "Unable to get canonical name of client, err = %d",errno); - p->client = p->ipaddr; + strcpy (p->client, p->ipaddr); } /* Save the cannonical name of the client host in the POP parameter block */ @@ -176,12 +177,13 @@ pop_init(POP *p,int argcount,char **argmessage) pop_log(p,POP_PRIORITY, "Client at \"%s\" resolves to an unknown host name \"%s\"", p->ipaddr,ch->h_name); - p->client = p->ipaddr; + strcpy (p->client, p->ipaddr); } else { /* Save the host name (the previous value was destroyed by gethostbyname) */ - p->client = ch_again->h_name; + strncpy (p->client, ch_again->h_name, sizeof(p->client)); + p->client[sizeof(p->client) - 1] = '\0'; /* Look for the client's IP address in the list returned for its name */ @@ -194,7 +196,7 @@ pop_init(POP *p,int argcount,char **argmessage) pop_log (p,POP_PRIORITY, "Client address \"%s\" not listed for its host name \"%s\"", p->ipaddr,ch->h_name); - p->client = p->ipaddr; + strcpy (p->client, p->ipaddr); } } }