summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-10-16 20:57:53 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-10-16 20:57:53 +0000
commitbe408c87bdf05935bdfc24ac463dfbba7fdb9559 (patch)
tree5b3b09a0bd7149a66e887430a330fdc9b4957d4e
parent1c5bf77d2c9607a4739b64c0197d923276ae04c7 (diff)
snprintf
-rw-r--r--usr.bin/ssh/auth-skey.c7
-rw-r--r--usr.bin/ssh/clientloop.c22
-rw-r--r--usr.bin/ssh/pty.c6
3 files changed, 18 insertions, 17 deletions
diff --git a/usr.bin/ssh/auth-skey.c b/usr.bin/ssh/auth-skey.c
index fe3103bd352..9ec17049438 100644
--- a/usr.bin/ssh/auth-skey.c
+++ b/usr.bin/ssh/auth-skey.c
@@ -1,5 +1,5 @@
#include "includes.h"
-RCSID("$Id: auth-skey.c,v 1.1 1999/10/07 21:45:02 markus Exp $");
+RCSID("$Id: auth-skey.c,v 1.2 1999/10/16 20:57:52 deraadt Exp $");
#include "ssh.h"
#include <sha1.h>
@@ -116,7 +116,7 @@ skey_fake_keyinfo(char *username)
memset(up, 0, 20); /* SHA1 specific */
free(up);
- (void)sprintf(skeyprompt,
+ (void)snprintf(skeyprompt, sizeof skeyprompt,
"otp-%.*s %d %.*s",
SKEY_MAX_HASHNAME_LEN,
skey_get_algorithm(),
@@ -139,7 +139,8 @@ skey_fake_keyinfo(char *username)
} while (--i != 0);
pbuf[12] = '\0';
- (void)sprintf(skeyprompt, "otp-%.*s %d %.*s",
+ (void)snprintf(skeyprompt, sizeof skeyprompt,
+ "otp-%.*s %d %.*s",
SKEY_MAX_HASHNAME_LEN,
skey_get_algorithm(),
99, SKEY_MAX_SEED_LEN, pbuf);
diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c
index 2cc7dad0cb5..b258d83460b 100644
--- a/usr.bin/ssh/clientloop.c
+++ b/usr.bin/ssh/clientloop.c
@@ -15,7 +15,7 @@ The main loop for the interactive session (client side).
*/
#include "includes.h"
-RCSID("$Id: clientloop.c,v 1.6 1999/09/30 08:34:24 deraadt Exp $");
+RCSID("$Id: clientloop.c,v 1.7 1999/10/16 20:57:52 deraadt Exp $");
#include "xmalloc.h"
#include "ssh.h"
@@ -423,7 +423,7 @@ void client_wait_until_can_do_something(fd_set *readset, fd_set *writeset)
if (errno == EINTR)
return;
/* Note: we might still have data in the buffers. */
- sprintf(buf, "select: %.100s\r\n", strerror(errno));
+ snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno));
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
quit_pending = 1;
@@ -491,7 +491,7 @@ void client_process_input(fd_set *readset)
if (len == 0)
{
/* Received EOF. The remote host has closed the connection. */
- sprintf(buf, "Connection to %.300s closed by remote host.\r\n",
+ snprintf(buf, sizeof buf, "Connection to %.300s closed by remote host.\r\n",
host);
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
@@ -508,7 +508,7 @@ void client_process_input(fd_set *readset)
{
/* An error has encountered. Perhaps there is a network
problem. */
- sprintf(buf, "Read from remote host %.300s: %.100s\r\n",
+ snprintf(buf, sizeof buf, "Read from remote host %.300s: %.100s\r\n",
host, strerror(errno));
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
@@ -530,7 +530,7 @@ void client_process_input(fd_set *readset)
an error condition. */
if (len < 0)
{
- sprintf(buf, "read: %.100s\r\n", strerror(errno));
+ snprintf(buf, sizeof buf, "read: %.100s\r\n", strerror(errno));
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
}
@@ -576,7 +576,7 @@ void client_process_input(fd_set *readset)
{
case '.':
/* Terminate the connection. */
- sprintf(buf, "%c.\r\n", escape_char);
+ snprintf(buf, sizeof buf, "%c.\r\n", escape_char);
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
quit_pending = 1;
@@ -585,7 +585,7 @@ void client_process_input(fd_set *readset)
case 'Z' - 64:
/* Suspend the program. */
/* Print a message to that effect to the user. */
- sprintf(buf, "%c^Z\r\n", escape_char);
+ snprintf(buf, sizeof buf, "%c^Z\r\n", escape_char);
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
@@ -640,7 +640,7 @@ void client_process_input(fd_set *readset)
continue;
case '?':
- sprintf(buf, "%c?\r\n\
+ snprintf(buf, sizeof buf, "%c?\r\n\
Supported escape sequences:\r\n\
~. - terminate connection\r\n\
~^Z - suspend ssh\r\n\
@@ -654,7 +654,7 @@ Supported escape sequences:\r\n\
continue;
case '#':
- sprintf(buf, "%c#\r\n", escape_char);
+ snprintf(buf, sizeof buf, "%c#\r\n", escape_char);
buffer_append(&stderr_buffer, buf, strlen(buf));
s = channel_open_message();
buffer_append(&stderr_buffer, s, strlen(s));
@@ -723,7 +723,7 @@ void client_process_output(fd_set *writeset)
{
/* An error or EOF was encountered. Put an error message
to stderr buffer. */
- sprintf(buf, "write stdout: %.50s\r\n", strerror(errno));
+ snprintf(buf, sizeof buf, "write stdout: %.50s\r\n", strerror(errno));
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
quit_pending = 1;
@@ -868,7 +868,7 @@ int client_loop(int have_pty, int escape_char_arg)
the connection has been closed. */
if (have_pty && !quiet_flag)
{
- sprintf(buf, "Connection to %.64s closed.\r\n", host);
+ snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host);
buffer_append(&stderr_buffer, buf, strlen(buf));
stderr_bytes += strlen(buf);
}
diff --git a/usr.bin/ssh/pty.c b/usr.bin/ssh/pty.c
index d9b7968077c..5b685dc01a2 100644
--- a/usr.bin/ssh/pty.c
+++ b/usr.bin/ssh/pty.c
@@ -14,7 +14,7 @@ Allocating a pseudo-terminal, and making it the controlling tty.
*/
#include "includes.h"
-RCSID("$Id: pty.c,v 1.4 1999/09/30 05:19:57 deraadt Exp $");
+RCSID("$Id: pty.c,v 1.5 1999/10/16 20:57:52 deraadt Exp $");
#include "pty.h"
#include "ssh.h"
@@ -163,12 +163,12 @@ int pty_allocate(int *ptyfd, int *ttyfd, char *namebuf)
for (i = 0; i < num_ptys; i++)
{
- sprintf(buf, "/dev/pty%c%c", ptymajors[i / num_minors],
+ snprintf(buf, sizeof buf, "/dev/pty%c%c", ptymajors[i / num_minors],
ptyminors[i % num_minors]);
*ptyfd = open(buf, O_RDWR|O_NOCTTY);
if (*ptyfd < 0)
continue;
- sprintf(namebuf, "/dev/tty%c%c", ptymajors[i / num_minors],
+ snprintf(namebuf, sizeof buf, "/dev/tty%c%c", ptymajors[i / num_minors],
ptyminors[i % num_minors]);
/* Open the slave side. */