diff options
author | 2015-01-19 16:40:49 +0000 | |
---|---|---|
committer | 2015-01-19 16:40:49 +0000 | |
commit | 38bc45fc2277bb8b79fc210a7497a386cebe2798 (patch) | |
tree | b43a2bc62c47df6d18a595bc3d173023efb123e5 | |
parent | Make use of an msr available on recent Intel processors to obtain the (diff) | |
download | wireguard-openbsd-38bc45fc2277bb8b79fc210a7497a386cebe2798.tar.xz wireguard-openbsd-38bc45fc2277bb8b79fc210a7497a386cebe2798.zip |
Replace HOST_NAME_MAX+1 with NI_MAXHOST when the hostname is used
with getaddrinfo() or getnameinfo(), but keep HOST_NAME_MAX+1 when
the hostname comes from gethostname().
No binary change; OK deraadt@
-rw-r--r-- | usr.sbin/syslogd/privsep.c | 12 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 12 |
2 files changed, 13 insertions, 11 deletions
diff --git a/usr.sbin/syslogd/privsep.c b/usr.sbin/syslogd/privsep.c index 9e527943a41..49c66b5cbbb 100644 --- a/usr.sbin/syslogd/privsep.c +++ b/usr.sbin/syslogd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.50 2015/01/16 06:40:21 deraadt Exp $ */ +/* $OpenBSD: privsep.c,v 1.51 2015/01/19 16:40:49 bluhm Exp $ */ /* * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org> @@ -23,9 +23,11 @@ #include <sys/socket.h> #include <sys/stat.h> #include <sys/wait.h> + #include <err.h> #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <netdb.h> #include <paths.h> #include <poll.h> @@ -37,7 +39,7 @@ #include <unistd.h> #include <util.h> #include <utmp.h> -#include <limits.h> + #include "syslogd.h" /* @@ -103,8 +105,8 @@ 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[PATH_MAX], protoname[5], hostname[HOST_NAME_MAX+1]; - char servname[NI_MAXSERV]; + char path[PATH_MAX], protoname[5]; + char hostname[NI_MAXHOST], servname[NI_MAXSERV]; struct sockaddr_storage addr; struct stat cf_stat; struct passwd *pw; @@ -699,7 +701,7 @@ int priv_getaddrinfo(char *proto, char *host, char *serv, struct sockaddr *addr, size_t addr_len) { - char protocpy[5], hostcpy[HOST_NAME_MAX+1], servcpy[NI_MAXSERV]; + char protocpy[5], hostcpy[NI_MAXHOST], servcpy[NI_MAXSERV]; int cmd, ret_len; size_t protoname_len, hostname_len, servname_len; diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 915cba56475..923a86c2677 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.143 2015/01/18 19:37:59 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.144 2015/01/19 16:40:49 bluhm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -81,10 +81,11 @@ #include <arpa/inet.h> #include <ctype.h> -#include <errno.h> #include <err.h> +#include <errno.h> #include <event.h> #include <fcntl.h> +#include <limits.h> #include <paths.h> #include <poll.h> #include <signal.h> @@ -93,7 +94,6 @@ #include <string.h> #include <tls.h> #include <unistd.h> -#include <limits.h> #include <utmp.h> #include <vis.h> @@ -135,7 +135,7 @@ struct filed { union { char f_uname[MAXUNAMES][UT_NAMESIZE+1]; struct { - char f_loghost[1+4+3+1+HOST_NAME_MAX+1+1+NI_MAXSERV]; + char f_loghost[1+4+3+1+NI_MAXHOST+1+NI_MAXSERV]; /* @proto46://[hostname]:servname\0 */ struct sockaddr_storage f_addr; struct buffertls f_buftls; @@ -653,7 +653,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[HOST_NAME_MAX+1]; + char resolve[NI_MAXHOST]; linebuf[n] = '\0'; cvthname((struct sockaddr *)&sa, resolve, sizeof(resolve)); @@ -1825,7 +1825,7 @@ cfline(char *line, char *prog) logerror(ebuf); break; } - if (strlen(host) >= HOST_NAME_MAX+1) { + if (strlen(host) >= NI_MAXHOST) { snprintf(ebuf, sizeof(ebuf), "host too long \"%s\"", f->f_un.f_forw.f_loghost); logerror(ebuf); |