From f360d1effefe16f6cbd4d0eeeaae4f3ba340c789 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Tue, 24 Dec 1996 17:01:49 +0000 Subject: [PATCH] Another one-liner: remember to NUL terminate local copy of NIS host lookup results. Without this, doing multiple host/addr lookups in a single process yeilds strange results (the buffer is static, and garbage may be left behind from previous lookups). I just noticed this in 2.2-BETA. Unless somebody threatens to chop my hands off with an axe, I'm going to move this to the 2.2-RELENG branch shortly. --- lib/libc/net/gethostbynis.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c index 24be897d371..c1f15e6e309 100644 --- a/lib/libc/net/gethostbynis.c +++ b/lib/libc/net/gethostbynis.c @@ -24,8 +24,8 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)$Id: gethostbynis.c,v 1.3 1996/07/12 18:54:35 jkh Exp $"; -static char rcsid[] = "$Id: gethostbynis.c,v 1.3 1996/07/12 18:54:35 jkh Exp $"; +static char sccsid[] = "@(#)$Id: gethostbynis.c,v 1.4 1996/08/29 20:07:54 peter Exp $"; +static char rcsid[] = "$Id: gethostbynis.c,v 1.4 1996/08/29 20:07:54 peter Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -85,6 +85,7 @@ _gethostbynis(name, map, af) /* avoid potential memory leak */ bcopy((char *)result, (char *)&ypbuf, resultlen); + ypbuf[resultlen] = '\0'; free(result); result = (char *)&ypbuf;