summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcloder <cloder@openbsd.org>2005-03-05 23:15:19 +0000
committercloder <cloder@openbsd.org>2005-03-05 23:15:19 +0000
commita6cb7df7657781401427ff3134ef5f64bee6f1af (patch)
tree93991551f5a933128a7223e1c613b6e7a092335f
parentCheck snprintf return value for -1. (diff)
downloadwireguard-openbsd-a6cb7df7657781401427ff3134ef5f64bee6f1af.tar.xz
wireguard-openbsd-a6cb7df7657781401427ff3134ef5f64bee6f1af.zip
Check snprintf return value for failure. Also fix a dumb error message.
OK otto, henning, hshoexer, krw. Some input from Moritz which I have chosen not to heed because I think the code is easier to read my way.
-rw-r--r--libexec/tftpd/tftpd.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index fbe0bcc6546..8352fcc144a 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftpd.c,v 1.38 2005/03/04 09:40:44 otto Exp $ */
+/* $OpenBSD: tftpd.c,v 1.39 2005/03/05 23:15:19 cloder Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -37,7 +37,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)tftpd.c 5.13 (Berkeley) 2/26/91";*/
-static char rcsid[] = "$OpenBSD: tftpd.c,v 1.38 2005/03/04 09:40:44 otto Exp $";
+static char rcsid[] = "$OpenBSD: tftpd.c,v 1.39 2005/03/05 23:15:19 cloder Exp $";
#endif /* not lint */
/*
@@ -702,10 +702,14 @@ oack(void)
if (options[i].o_request) {
n = snprintf(bp, size, "%s%c%d", options[i].o_type,
0, options[i].o_reply);
+ if (n == -1 || n >= size) {
+ syslog(LOG_ERR, "oack: no buffer space");
+ exit(1);
+ }
bp += n+1;
size -= n+1;
if (size < 0) {
- syslog(LOG_ERR, "oack: buffer overflow");
+ syslog(LOG_ERR, "oack: no buffer space");
exit(1);
}
}