diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-07-08 18:09:54 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-09-06 23:22:06 -0700 |
commit | 492f785b78c4ce039eea794c4a7762532cc5f97c (patch) | |
tree | 6ac4eb7866c0697bedf66ef43502bbffb92a607a | |
parent | fb37ebcf57db7a3743f0f78c0a123c9f34a2a2df (diff) |
Convert remaining sprintf calls to snprintf
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
-rw-r--r-- | common.c | 2 | ||||
-rw-r--r-- | fd.c | 8 | ||||
-rw-r--r-- | prtype.c | 4 | ||||
-rw-r--r-- | scope.c | 6 |
4 files changed, 11 insertions, 9 deletions
@@ -217,7 +217,7 @@ SetUpConnectionSocket(int iport, void (*connectionFunc) (int)) #ifdef USE_XTRANS ScopePort = iport - ServerBasePort; - sprintf(port, "%d", ScopePort); + snprintf(port, sizeof(port), "%d", ScopePort); if ((_X11TransMakeAllCOTSServerListeners(port, &partial, &ListenTransCount, &ListenTransConns) >= 0) && (ListenTransCount >= 1)) { @@ -311,7 +311,8 @@ MakeConnection(const char *server, short port, int report, /* determine the host machine for this process */ if (*server == '\0') { sun.sun_family = AF_UNIX; - sprintf(sun.sun_path, "/tmp/.X11-unix/X%d", port - 6000); + snprintf(sun.sun_path, sizeof(sun.sun_path), + "/tmp/.X11-unix/X%d", port - 6000); salen = sizeof(sun.sun_family) + strlen(sun.sun_path) + 1; saddr = (struct sockaddr *) &sun; } @@ -335,8 +336,9 @@ MakeConnection(const char *server, short port, int report, if (port == ScopePort && strcmp(server, ScopeHost) == 0) { char error_message[100]; - (void) sprintf(error_message, "Trying to attach to myself: %s,%d\n", - server, sin.sin_port); + snprintf(error_message, sizeof(error_message), + "Trying to attach to myself: %s,%d\n", + server, sin.sin_port); panic(error_message); } @@ -99,7 +99,7 @@ printrep(unsigned short c) } else { /* very large number -- print as 0xffff - 4 digit hex */ - sprintf(pr, "0x%04x", c); + snprintf(pr, sizeof(pr), "0x%04x", c); } return (pr); } @@ -1056,7 +1056,7 @@ DumpHexBuffer(const unsigned char *buf, long n) char h[6]; /* one hex or octal character */ /* get the hex representations */ - sprintf(h, "%02x", (0xff & buf[i])); + snprintf(h, sizeof(h), "%02x", (0xff & buf[i])); /* check if these characters will fit on this line */ if ((column + strlen(h) + 1) > MAXline) { @@ -968,7 +968,7 @@ ClientName(FD fd) if (clientNumber <= 1) return (""); - (void) sprintf(name, " %d", FDinfo[fd].ClientNumber); + snprintf(name, sizeof(name), " %d", FDinfo[fd].ClientNumber); return (name); } @@ -1215,8 +1215,8 @@ ConnectToServer(Boolean report) { char error_message[100]; - sprintf(error_message, "Trying to attach to myself: %s,%d\n", - ServerHostName, port); + snprintf(error_message, sizeof(error_message), + "Trying to attach to myself: %s,%d\n", ServerHostName, port); panic(error_message); } |