From df5766bd4b7b020c54f683ebd24ab233defb74a9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 6 Sep 2009 00:54:06 +0200 Subject: rexec.c: small code shrink text data bss dec hex filename - 1223 0 0 1223 4c7 libc/inet/rpc/rexec.o + 1214 0 0 2239 8bf libc/inet/rpc/rexec.o Signed-off-by: Denys Vlasenko --- libc/inet/rpc/rexec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libc/inet/rpc/rexec.c') 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; -- cgit v1.2.3