do not refer free'ed memory region. KAME PR 302 from ryo@iij.ad.jp

This commit is contained in:
itojun 2000-11-09 01:04:14 +00:00
parent ccf7f1446f
commit 7b0d3f1d84
2 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rlogind.c,v 1.21 2000/04/14 12:29:49 itojun Exp $ */
/* $NetBSD: rlogind.c,v 1.22 2000/11/09 01:04:14 itojun Exp $ */
/*
* Copyright (C) 1998 WIDE Project.
@ -73,7 +73,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)rlogind.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: rlogind.c,v 1.21 2000/04/14 12:29:49 itojun Exp $");
__RCSID("$NetBSD: rlogind.c,v 1.22 2000/11/09 01:04:14 itojun Exp $");
#endif
#endif /* not lint */
@ -299,6 +299,7 @@ doit(f, fromp)
* address corresponds to the name.
*/
hostname = saddr;
res0 = NULL;
if (check_all || local_domain(saddr)) {
strncpy(hostnamebuf, saddr, sizeof(hostnamebuf) - 1);
hostnamebuf[sizeof(hostnamebuf) - 1] = 0;
@ -337,11 +338,12 @@ doit(f, fromp)
: saddr);
hostname = naddr;
}
freeaddrinfo(res0);
}
}
hostname = strncpy(hostnamebuf, hostname,
sizeof(hostnamebuf) - 1);
if (res0)
freeaddrinfo(res0);
} else
hostname = strncpy(hostnamebuf, naddr,
sizeof(hostnamebuf) - 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rshd.c,v 1.20 2000/10/10 19:54:39 is Exp $ */
/* $NetBSD: rshd.c,v 1.21 2000/11/09 01:04:14 itojun Exp $ */
/*
* Copyright (C) 1998 WIDE Project.
@ -73,7 +73,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1992, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
#else
__RCSID("$NetBSD: rshd.c,v 1.20 2000/10/10 19:54:39 is Exp $");
__RCSID("$NetBSD: rshd.c,v 1.21 2000/11/09 01:04:14 itojun Exp $");
#endif
#endif /* not lint */
@ -371,6 +371,7 @@ doit(fromp)
* address corresponds to the name.
*/
hostname = saddr;
res0 = NULL;
if (check_all || local_domain(saddr)) {
strncpy(remotehost, saddr, sizeof(remotehost) - 1);
remotehost[sizeof(remotehost) - 1] = 0;
@ -414,11 +415,12 @@ doit(fromp)
"Host address mismatch for %s\n";
hostname = naddr;
}
freeaddrinfo(res0);
}
}
hostname = strncpy(hostnamebuf, hostname,
sizeof(hostnamebuf) - 1);
if (res0)
freeaddrinfo(res0);
} else {
errorhost = hostname = strncpy(hostnamebuf,
naddr, sizeof(hostnamebuf) - 1);