Browse Source

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 <vda.linux@googlemail.com>
Denys Vlasenko 14 years ago
parent
commit
df5766bd4b
1 changed files with 6 additions and 2 deletions
  1. 6 2
      libc/inet/rpc/rexec.c

+ 6 - 2
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;