diff options
author | Moritz Jodeit <moritz@cvs.openbsd.org> | 2005-04-28 10:17:57 +0000 |
---|---|---|
committer | Moritz Jodeit <moritz@cvs.openbsd.org> | 2005-04-28 10:17:57 +0000 |
commit | d4d4b1387981f640d52bb7584d0bc5096cd091bb (patch) | |
tree | 109e5e4182c59a24880784e5bd02c281ab0d79db | |
parent | c03673c973f7237b76ad78761d9af76d16e1746e (diff) |
add snprintf checks. ok djm@ markus@
-rw-r--r-- | usr.bin/ssh/progressmeter.c | 4 | ||||
-rw-r--r-- | usr.bin/ssh/ssh-keyscan.c | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/ssh/progressmeter.c b/usr.bin/ssh/progressmeter.c index 40c7f93ec7a..5686fc25ba4 100644 --- a/usr.bin/ssh/progressmeter.c +++ b/usr.bin/ssh/progressmeter.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: progressmeter.c,v 1.22 2004/07/11 17:48:47 deraadt Exp $"); +RCSID("$OpenBSD: progressmeter.c,v 1.23 2005/04/28 10:17:56 moritz Exp $"); #include "progressmeter.h" #include "atomicio.h" @@ -146,6 +146,8 @@ refresh_progress_meter(void) len = snprintf(buf, file_len + 1, "\r%s", file); if (len < 0) len = 0; + if (len >= file_len + 1) + len = file_len; for (i = len; i < file_len; i++ ) buf[i] = ' '; buf[file_len] = '\0'; diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index b33d8637768..15dfb9c46e7 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/ssh-keyscan.c @@ -7,7 +7,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keyscan.c,v 1.52 2005/03/01 15:47:14 jmc Exp $"); +RCSID("$OpenBSD: ssh-keyscan.c,v 1.53 2005/04/28 10:17:56 moritz Exp $"); #include <sys/queue.h> #include <errno.h> @@ -534,6 +534,11 @@ congreet(int s) n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n", c->c_keytype == KT_RSA1? PROTOCOL_MAJOR_1 : PROTOCOL_MAJOR_2, c->c_keytype == KT_RSA1? PROTOCOL_MINOR_1 : PROTOCOL_MINOR_2); + if (n == -1 || n >= sizeof buf) { + error("snprintf: buffer too small"); + confree(s); + return; + } if (atomicio(vwrite, s, buf, n) != n) { error("write (%s): %s", c->c_name, strerror(errno)); confree(s); |