aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/net/gethostbynis.c
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2019-08-12 20:27:33 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-08-12 20:27:33 +0000
commit6b462d2762d67c5d839020d6cc77052bbf2a18cd (patch)
treec34db7db1d9f957ee3ad8efecf57b06a29f10f68 /lib/libc/net/gethostbynis.c
parent26b6a67b98153462d8a708461c9479e7a9b3a16d (diff)
downloadsrc-6b462d2762d67c5d839020d6cc77052bbf2a18cd.tar.gz
src-6b462d2762d67c5d839020d6cc77052bbf2a18cd.zip
Increase YPMAXRECORD to 16M to be compatible with Linux.
Since YP protocol definition uses the constant to declare variable-size opaque byte strings, the change should be binary compatible with existing installations which do not expose keys or values larger than 1024 bytes. All uses of local variables with YPMAXRECORD sizes were removed to avoid insane stack use. On the other hand, variables with static lifetime should be fine and only result in increased VA use. Glibc made same change, increasing the allowed length for keys and values in YP to 16M, in 2013. Reviewed by: markj Discussed with: ian Sponsored by: Mellanox Technologies MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D20900
Notes
Notes: svn path=/head/; revision=350957
Diffstat (limited to 'lib/libc/net/gethostbynis.c')
-rw-r--r--lib/libc/net/gethostbynis.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c
index 9edee742e7e9..edc0a092ae10 100644
--- a/lib/libc/net/gethostbynis.c
+++ b/lib/libc/net/gethostbynis.c
@@ -58,7 +58,7 @@ _gethostbynis(const char *name, char *map, int af, struct hostent *he,
char *cp, **q;
char *result;
int resultlen, size, addrok = 0;
- char ypbuf[YPMAXRECORD + 2];
+ char *ypbuf;
res_state statp;
statp = __res_state();
@@ -88,10 +88,11 @@ _gethostbynis(const char *name, char *map, int af, struct hostent *he,
}
/* avoid potential memory leak */
- bcopy((char *)result, (char *)&ypbuf, resultlen);
+ ypbuf = alloca(resultlen + 2);
+ bcopy(result, ypbuf, resultlen);
ypbuf[resultlen] = '\0';
free(result);
- result = (char *)&ypbuf;
+ result = ypbuf;
if ((cp = strchr(result, '\n')))
*cp = '\0';