From a574f01947321cfc4dc746db90c2291f3e9f10c2 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 13 Dec 2015 23:40:36 +0100 Subject: dynamically allocate ahostbuf buffer Free 1k of static data (.bss) Signed-off-by: Leonid Lisovskiy Signed-off-by: Waldemar Brodkorb --- libc/inet/rpc/rexec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libc/inet') diff --git a/libc/inet/rpc/rexec.c b/libc/inet/rpc/rexec.c index 9f7cc80e3..e17be50b2 100644 --- a/libc/inet/rpc/rexec.c +++ b/libc/inet/rpc/rexec.c @@ -39,12 +39,13 @@ #include #include #include +#include #define SA_LEN(_x) __libc_sa_len((_x)->sa_family) extern int __libc_sa_len(sa_family_t __af) __THROW attribute_hidden; /* int rexecoptions; - google does not know it */ -static char ahostbuf[NI_MAXHOST]; +static char *ahostbuf = NULL; int rexec_af(char **ahost, int rport, const char *name, const char *pass, const char *cmd, int *fd2p, sa_family_t af) @@ -77,8 +78,10 @@ rexec_af(char **ahost, int rport, const char *name, const char *pass, const char } if (res0->ai_canonname) { - strncpy(ahostbuf, res0->ai_canonname, sizeof(ahostbuf)); - ahostbuf[sizeof(ahostbuf)-1] = '\0'; + if (!ahostbuf) + ahostbuf = __uc_malloc(NI_MAXHOST); + strncpy(ahostbuf, res0->ai_canonname, NI_MAXHOST); + ahostbuf[NI_MAXHOST-1] = '\0'; *ahost = ahostbuf; } else { -- cgit v1.2.3