From 757849cd93a9bc361a5113e3aaafe516773aad44 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 23 Nov 2013 22:23:52 -0500 Subject: [SV 40361] Don't use vsnprintf(), which is an ISO C99 function. * output.c (error, fatal, message): Take an extra argument specifying how many bytes are used by the formatted arguments. (get_buffer): New function that allocates the requested buffer size. Remove msc_vsnprintf(), vfmtconcat(), and fmtconcat() as unneeded. * makeint.h: Declare various helper macros for generating output. * *.c: Change all error(), fatal(), message() calls to use the macros, or pass the extra length argument directly. --- remote-cstms.c | 58 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'remote-cstms.c') diff --git a/remote-cstms.c b/remote-cstms.c index 8d6c635..a5ef99b 100644 --- a/remote-cstms.c +++ b/remote-cstms.c @@ -151,7 +151,7 @@ start_remote_job (char **argv, char **envp, int stdin_fd, retsock = Rpc_UdpCreate (True, 0); if (retsock < 0) { - error (NILF, "exporting: Couldn't create return socket."); + O (error, NILF, "exporting: Couldn't create return socket."); return 1; } @@ -192,33 +192,35 @@ start_remote_job (char **argv, char **envp, int stdin_fd, host = gethostbyaddr ((char *)&permit.addr, sizeof(permit.addr), AF_INET); - if (status != RPC_SUCCESS) - { - (void) close (retsock); - (void) close (sock); - error (NILF, "exporting to %s: %s", - host ? host->h_name : inet_ntoa (permit.addr), - Rpc_ErrorMessage (status)); - return 1; - } - else if (msg[0] != 'O' || msg[1] != 'k' || msg[2] != '\0') - { - (void) close (retsock); - (void) close (sock); - error (NILF, "exporting to %s: %s", - host ? host->h_name : inet_ntoa (permit.addr), - msg); - return 1; - } - else - { - error (NILF, "*** exported to %s (id %u)", - host ? host->h_name : inet_ntoa (permit.addr), - permit.id); - } - - fflush (stdout); - fflush (stderr); + { + const char *hnm = host ? host->h_name : inet_ntoa (permit.addr); + size_t hlen = strlen (hnm); + + if (status != RPC_SUCCESS) + { + const char *err = Rpc_ErrorMessage (status); + (void) close (retsock); + (void) close (sock); + error (NILF, hlen + strlen (err), + "exporting to %s: %s", hnm, err); + return 1; + } + else if (msg[0] != 'O' || msg[1] != 'k' || msg[2] != '\0') + { + (void) close (retsock); + (void) close (sock); + error (NILF, hlen + strlen (msg), "exporting to %s: %s", hnm, msg); + return 1; + } + else + { + error (NILF, hlen + INTSTR_LENGTH, + "*** exported to %s (id %u)", hnm, permit.id); + } + + fflush (stdout); + fflush (stderr); + } pid = fork (); if (pid < 0) -- cgit v1.2.3