diff options
| author | 2007-03-02 11:37:53 +0000 | |
|---|---|---|
| committer | 2007-03-02 11:37:53 +0000 | |
| commit | 8065ecebaf22de144e59f4608de6265da63971a5 (patch) | |
| tree | 926da206e41d60339248ac1bbba43972e00b71ad /usr.sbin/dhcpd/errwarn.c | |
| parent | when the http read callback changes and some data is still left in the (diff) | |
| download | wireguard-openbsd-8065ecebaf22de144e59f4608de6265da63971a5.tar.xz wireguard-openbsd-8065ecebaf22de144e59f4608de6265da63971a5.zip | |
pull in spaces array overflow fixes from dhclient
the code here is slightly different, but also has the overfow in both cases
Diffstat (limited to 'usr.sbin/dhcpd/errwarn.c')
| -rw-r--r-- | usr.sbin/dhcpd/errwarn.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/dhcpd/errwarn.c b/usr.sbin/dhcpd/errwarn.c index 9d92d1cde9d..70bc1830594 100644 --- a/usr.sbin/dhcpd/errwarn.c +++ b/usr.sbin/dhcpd/errwarn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: errwarn.c,v 1.6 2005/04/18 16:39:25 moritz Exp $ */ +/* $OpenBSD: errwarn.c,v 1.7 2007/03/02 11:37:53 henning Exp $ */ /* Errors and warnings... */ @@ -199,6 +199,7 @@ parse_warn(char *fmt, ...) " " " "; /* 80 spaces */ struct iovec iov[6]; + size_t iovcnt; do_percentm(mbuf, sizeof(mbuf), fmt); snprintf(fbuf, sizeof(fbuf), "%s line %d: %s", tlname, lexline, mbuf); @@ -215,17 +216,20 @@ parse_warn(char *fmt, ...) iov[2].iov_len = strlen(token_line); iov[3].iov_base = "\n"; iov[3].iov_len = 1; - iov[4].iov_base = spaces; - iov[4].iov_len = lexchar - 1; - iov[5].iov_base = "^\n"; - iov[5].iov_len = 2; - writev(STDERR_FILENO, iov, sizeof(iov)/sizeof(iov[0])); + iovcnt = 4; + if (lexchar < 81) { + iov[4].iov_base = spaces; + iov[4].iov_len = lexchar - 1; + iov[5].iov_base = "^\n"; + iov[5].iov_len = 2; + iovcnt += 2; + } + writev(STDERR_FILENO, iov, iovcnt); } else { syslog(log_priority | LOG_ERR, "%s", mbuf); syslog(log_priority | LOG_ERR, "%s", token_line); - if (lexline < 81) - syslog(log_priority | LOG_ERR, - "%s^", &spaces[sizeof(spaces) - lexchar]); + if (lexchar < 81) + syslog(log_priority | LOG_ERR, "%*c", lexchar, '^'); } warnings_occurred = 1; |
