diff options
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/privsep.c | 19 | ||||
-rw-r--r-- | usr.sbin/syslogd/privsep_fdpass.c | 4 | ||||
-rw-r--r-- | usr.sbin/syslogd/ringbuf.c | 11 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 20 | ||||
-rw-r--r-- | usr.sbin/syslogd/ttymsg.c | 4 |
5 files changed, 31 insertions, 27 deletions
diff --git a/usr.sbin/syslogd/privsep.c b/usr.sbin/syslogd/privsep.c index b69d687c087..9e527943a41 100644 --- a/usr.sbin/syslogd/privsep.c +++ b/usr.sbin/syslogd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.49 2014/12/31 13:55:57 bluhm Exp $ */ +/* $OpenBSD: privsep.c,v 1.50 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org> @@ -15,8 +15,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + #include <sys/ioctl.h> -#include <sys/param.h> #include <sys/queue.h> #include <sys/uio.h> #include <sys/types.h> @@ -37,6 +37,7 @@ #include <unistd.h> #include <util.h> #include <utmp.h> +#include <limits.h> #include "syslogd.h" /* @@ -74,14 +75,14 @@ enum cmd_types { static int priv_fd = -1; static volatile pid_t child_pid = -1; -static char config_file[MAXPATHLEN]; +static char config_file[PATH_MAX]; static struct stat cf_info; static int allow_getnameinfo = 0; static volatile sig_atomic_t cur_state = STATE_INIT; /* Queue for the allowed logfiles */ struct logname { - char path[MAXPATHLEN]; + char path[PATH_MAX]; TAILQ_ENTRY(logname) next; }; static TAILQ_HEAD(, logname) lognames; @@ -102,7 +103,7 @@ priv_init(char *conf, int numeric, int lockfd, int nullfd, char *argv[]) { int i, fd, socks[2], cmd, addr_len, result, restart; size_t path_len, protoname_len, hostname_len, servname_len; - char path[MAXPATHLEN], protoname[5], hostname[MAXHOSTNAMELEN]; + char path[PATH_MAX], protoname[5], hostname[HOST_NAME_MAX+1]; char servname[NI_MAXSERV]; struct sockaddr_storage addr; struct stat cf_stat; @@ -527,7 +528,7 @@ check_log_name(char *lognam, size_t logsize) lg = malloc(sizeof(struct logname)); if (!lg) err(1, "check_log_name() malloc"); - strlcpy(lg->path, lognam, MAXPATHLEN); + strlcpy(lg->path, lognam, PATH_MAX); TAILQ_INSERT_TAIL(&lognames, lg, next); break; case STATE_RUNNING: @@ -564,7 +565,7 @@ increase_state(int state) int priv_open_tty(const char *tty) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; int cmd, fd; size_t path_len; @@ -587,7 +588,7 @@ priv_open_tty(const char *tty) int priv_open_log(const char *lognam) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; int cmd, fd; size_t path_len; @@ -698,7 +699,7 @@ int priv_getaddrinfo(char *proto, char *host, char *serv, struct sockaddr *addr, size_t addr_len) { - char protocpy[5], hostcpy[MAXHOSTNAMELEN], servcpy[NI_MAXSERV]; + char protocpy[5], hostcpy[HOST_NAME_MAX+1], servcpy[NI_MAXSERV]; int cmd, ret_len; size_t protoname_len, hostname_len, servname_len; diff --git a/usr.sbin/syslogd/privsep_fdpass.c b/usr.sbin/syslogd/privsep_fdpass.c index 6984929fa9e..4ae2ee272fd 100644 --- a/usr.sbin/syslogd/privsep_fdpass.c +++ b/usr.sbin/syslogd/privsep_fdpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep_fdpass.c,v 1.8 2012/04/04 17:24:50 deraadt Exp $ */ +/* $OpenBSD: privsep_fdpass.c,v 1.9 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright 2001 Niels Provos <provos@citi.umich.edu> @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> + #include <sys/uio.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/syslogd/ringbuf.c b/usr.sbin/syslogd/ringbuf.c index 80f06fe603d..1af7d7d6fa0 100644 --- a/usr.sbin/syslogd/ringbuf.c +++ b/usr.sbin/syslogd/ringbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ringbuf.c,v 1.7 2005/09/21 23:25:32 djm Exp $ */ +/* $OpenBSD: ringbuf.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2004 Damien Miller @@ -21,13 +21,14 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "syslogd.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* Initialise a ring buffer */ struct ringbuf * ringbuf_init(size_t len) @@ -141,7 +142,7 @@ ringbuf_to_string(char *buf, size_t len, struct ringbuf *rb) if (buf == NULL || rb == NULL || len == 0) return (-1); - copy_len = MIN(len - 1, ringbuf_used(rb)); + copy_len = MINIMUM(len - 1, ringbuf_used(rb)); if (copy_len == 0) return (copy_len); @@ -151,9 +152,9 @@ ringbuf_to_string(char *buf, size_t len, struct ringbuf *rb) else { /* If the buffer is wrapped, copy each hunk separately */ n = rb->len - rb->start; - memcpy(buf, rb->buf + rb->start, MIN(n, copy_len)); + memcpy(buf, rb->buf + rb->start, MINIMUM(n, copy_len)); if (copy_len > n) - memcpy(buf + n, rb->buf, MIN(rb->end, copy_len - n)); + memcpy(buf + n, rb->buf, MINIMUM(rb->end, copy_len - n)); } buf[copy_len] = '\0'; diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index d70fd9f6a2a..c94936e342d 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.141 2015/01/15 11:49:59 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.142 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -64,7 +64,6 @@ #define TIMERINTVL 30 /* interval for checking flush, mark */ #define TTYMSGTIME 1 /* timeout passed to ttymsg */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/wait.h> @@ -93,9 +92,12 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <vis.h> +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #define SYSLOG_NAMES #include <sys/syslog.h> @@ -131,13 +133,13 @@ struct filed { union { char f_uname[MAXUNAMES][UT_NAMESIZE+1]; struct { - char f_loghost[1+4+3+1+MAXHOSTNAMELEN+1+NI_MAXSERV]; + char f_loghost[1+4+3+1+HOST_NAME_MAX+1+1+NI_MAXSERV]; /* @proto46://[hostname]:servname\0 */ struct sockaddr_storage f_addr; struct bufferevent *f_bufev; int f_reconnectwait; } f_forw; /* forwarding address */ - char f_fname[MAXPATHLEN]; + char f_fname[PATH_MAX]; struct { char f_mname[MAX_MEMBUF_NAME]; struct ringbuf *f_rb; @@ -148,7 +150,7 @@ struct filed { } f_un; char f_prevline[MAXSVLINE]; /* last message logged */ char f_lasttime[16]; /* time of last occurrence */ - char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ + char f_prevhost[HOST_NAME_MAX+1]; /* host from which recd. */ int f_prevpri; /* pri of f_prevline */ int f_prevlen; /* length of f_prevline */ int f_prevcount; /* repetition cnt of prevline */ @@ -194,7 +196,7 @@ int nunix = 1; /* Number of Unix domain sockets requested */ char *path_unix[MAXUNIX] = { _PATH_LOG }; /* Paths to Unix domain sockets */ int Debug; /* debug flag */ int Startup = 1; /* startup flag */ -char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ +char LocalHostName[HOST_NAME_MAX+1]; /* our hostname */ char *LocalDomain; /* our local domain name */ int Initialized = 0; /* set when we have initialized ourselves */ @@ -645,7 +647,7 @@ udp_readcb(int fd, short event, void *arg) salen = sizeof(sa); n = recvfrom(fd, linebuf, MAXLINE, 0, (struct sockaddr *)&sa, &salen); if (n > 0) { - char resolve[MAXHOSTNAMELEN]; + char resolve[HOST_NAME_MAX+1]; linebuf[n] = '\0'; cvthname((struct sockaddr *)&sa, resolve, sizeof(resolve)); @@ -1740,7 +1742,7 @@ cfline(char *line, char *prog) logerror(ebuf); break; } - if (strlen(host) >= MAXHOSTNAMELEN) { + if (strlen(host) >= HOST_NAME_MAX+1) { snprintf(ebuf, sizeof(ebuf), "host too long \"%s\"", f->f_un.f_forw.f_loghost); logerror(ebuf); @@ -1864,7 +1866,7 @@ cfline(char *line, char *prog) } /* Set buffer length */ - rb_len = MAX(rb_len, MIN_MEMBUF); + rb_len = MAXIMUM(rb_len, MIN_MEMBUF); f->f_un.f_mb.f_len = rb_len; f->f_un.f_mb.f_overflow = 0; f->f_un.f_mb.f_attached = 0; diff --git a/usr.sbin/syslogd/ttymsg.c b/usr.sbin/syslogd/ttymsg.c index 25313f3e08a..a611218cedd 100644 --- a/usr.sbin/syslogd/ttymsg.c +++ b/usr.sbin/syslogd/ttymsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttymsg.c,v 1.5 2014/08/25 18:05:30 bluhm Exp $ */ +/* $OpenBSD: ttymsg.c,v 1.6 2015/01/16 06:40:21 deraadt Exp $ */ /* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* nitems */ #include <sys/stat.h> #include <sys/types.h> #include <sys/uio.h> |