summaryrefslogtreecommitdiff
path: root/libc/inet
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-12-13 23:40:36 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2015-12-17 20:35:20 +0100
commita574f01947321cfc4dc746db90c2291f3e9f10c2 (patch)
tree833311a5561ef3b77aee15548b8fca88857f37b3 /libc/inet
parent8a783f5440817b8db8d27b6a3fb14c301ffa9ad7 (diff)
dynamically allocate ahostbuf buffer
Free 1k of static data (.bss) Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Diffstat (limited to 'libc/inet')
-rw-r--r--libc/inet/rpc/rexec.c9
1 files changed, 6 insertions, 3 deletions
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 <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <malloc.h>
#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 {