diff options
author | Paul Smith <psmith@gnu.org> | 2013-11-23 22:23:52 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2013-11-23 22:23:52 -0500 |
commit | 757849cd93a9bc361a5113e3aaafe516773aad44 (patch) | |
tree | d6acd1705fe25873b43fa7d16b736e44b6191ab7 /remote-cstms.c | |
parent | 9d58570c77240fed53d1f88217877f8e778f4bb2 (diff) | |
download | gunmake-757849cd93a9bc361a5113e3aaafe516773aad44.tar.gz |
[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.
Diffstat (limited to 'remote-cstms.c')
-rw-r--r-- | remote-cstms.c | 58 |
1 files changed, 30 insertions, 28 deletions
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) |