1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 16:42:56 -08:00

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@
This commit is contained in:
bluhm 2015-01-19 16:40:49 +00:00
parent 7a17d89036
commit 38bc45fc22
2 changed files with 13 additions and 11 deletions

View File

@ -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;

View File

@ -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);