summaryrefslogtreecommitdiff
path: root/libc/inet
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inet')
-rw-r--r--libc/inet/rpc/rexec.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libc/inet/rpc/rexec.c b/libc/inet/rpc/rexec.c
index 8305b4a20..11c4b9f83 100644
--- a/libc/inet/rpc/rexec.c
+++ b/libc/inet/rpc/rexec.c
@@ -83,8 +83,12 @@ rexec_af(char **ahost, int rport, const char *name, const char *pass, const char
int gai;
char servbuff[NI_MAXSERV];
- snprintf(servbuff, sizeof(servbuff), "%d", ntohs(rport));
- servbuff[sizeof(servbuff) - 1] = '\0';
+ if (sizeof(servbuff) < sizeof(int)*3 + 2) {
+ snprintf(servbuff, sizeof(servbuff), "%d", ntohs(rport));
+ servbuff[sizeof(servbuff) - 1] = '\0';
+ } else {
+ sprintf(servbuff, "%d", ntohs(rport));
+ }
memset(&hints, '\0', sizeof(hints));
hints.ai_family = af;