summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2010-04-04 07:02:10 +0000
committerume <ume@FreeBSD.org>2010-04-04 07:02:10 +0000
commit74ecc8e0c65300d46719c196619820b6d0d30e6f (patch)
treec6816abcb41cc9e30291c4b796a472f4869c9d95
parenta8e5a68f92d1b98cd8a8e8aada4d5d5ef1fa749f (diff)
downloadFreeBSD-src-74ecc8e0c65300d46719c196619820b6d0d30e6f.zip
FreeBSD-src-74ecc8e0c65300d46719c196619820b6d0d30e6f.tar.gz
Stop adding trailing '\n'. The servent_unpack() doesn't expect
lines terminated with '\n'. MFC after: 2 weeks
-rw-r--r--lib/libc/net/getservent.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c
index ebb7a7d..105dbfe 100644
--- a/lib/libc/net/getservent.c
+++ b/lib/libc/net/getservent.c
@@ -594,15 +594,13 @@ nis_servent(void *retval, void *mdata, va_list ap)
break;
};
- /* we need a room for additional \n symbol */
- if (bufsize <=
- resultbuflen + 1 + _ALIGNBYTES + sizeof(char *)) {
+ if (bufsize <= resultbuflen + _ALIGNBYTES + sizeof(char *)) {
*errnop = ERANGE;
rv = NS_RETURN;
break;
}
- aliases = (char **)_ALIGN(&buffer[resultbuflen + 2]);
+ aliases = (char **)_ALIGN(&buffer[resultbuflen + 1]);
aliases_size =
(buffer + bufsize - (char *)aliases) / sizeof(char *);
if (aliases_size < 1) {
@@ -611,13 +609,8 @@ nis_servent(void *retval, void *mdata, va_list ap)
break;
}
- /*
- * servent_unpack expects lines terminated with \n --
- * make it happy
- */
memcpy(buffer, resultbuf, resultbuflen);
- buffer[resultbuflen] = '\n';
- buffer[resultbuflen + 1] = '\0';
+ buffer[resultbuflen] = '\0';
if (servent_unpack(buffer, serv, aliases, aliases_size,
errnop) != 0) {
OpenPOWER on IntegriCloud