summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-08 18:09:54 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-10-02 22:14:45 -0700
commitf0df23d778ae5b85745de0e48729b039b5b3f69a (patch)
tree578786bf7dfc5e90cf70591e230118b881a127ae
parentd5cc5b0e6b4e9cd1ee35e58069018f75bb0a3ed3 (diff)
downloadxscope-f0df23d778ae5b85745de0e48729b039b5b3f69a.tar.gz
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.c2
-rw-r--r--fd.c8
-rw-r--r--prtype.c4
-rw-r--r--scope.c6
4 files changed, 11 insertions, 9 deletions
diff --git a/common.c b/common.c
index c0e9fd6..86bfca5 100644
--- a/common.c
+++ b/common.c
@@ -218,7 +218,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)) {
diff --git a/fd.c b/fd.c
index b6cea42..3d3a863 100644
--- a/fd.c
+++ b/fd.c
@@ -313,7 +313,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;
}
@@ -337,8 +338,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);
}
diff --git a/prtype.c b/prtype.c
index 1fb917d..d16647c 100644
--- a/prtype.c
+++ b/prtype.c
@@ -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);
}
@@ -1073,7 +1073,7 @@ DumpHexBuffer(const unsigned char *buf, long n)
column = 27 + SizeofLeader();
for (i = 0; i < n; i++) {
/* 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) {
diff --git a/scope.c b/scope.c
index 2f9befc..fc512f4 100644
--- a/scope.c
+++ b/scope.c
@@ -973,7 +973,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);
}
@@ -1220,8 +1220,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);
}