-/* $OpenBSD: privsep.c,v 1.36 2014/08/19 00:53:01 bluhm Exp $ */
+/* $OpenBSD: privsep.c,v 1.37 2014/08/20 19:16:27 bluhm Exp $ */
/*
* Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
PRIV_OPEN_UTMP, /* open utmp for reading only */
PRIV_OPEN_CONFIG, /* open config file for reading only */
PRIV_CONFIG_MODIFIED, /* check if config file has been modified */
- PRIV_GETHOSTSERV, /* resolve host/service names */
+ PRIV_GETADDRINFO, /* resolve host/service names */
PRIV_GETHOSTBYADDR, /* resolve numeric address into hostname */
PRIV_DONE_CONFIG_PARSE /* signal that the initial config parse is done */
};
increase_state(STATE_RUNNING);
break;
- case PRIV_GETHOSTSERV:
- dprintf("[priv]: msg PRIV_GETHOSTSERV received\n");
+ case PRIV_GETADDRINFO:
+ dprintf("[priv]: msg PRIV_GETADDRINFO received\n");
/* Expecting: len, hostname, len, servname */
must_read(socks[0], &hostname_len, sizeof(size_t));
- if (hostname_len == 0 || hostname_len > sizeof(hostname))
+ if (hostname_len == 0 ||
+ hostname_len > sizeof(hostname))
_exit(1);
must_read(socks[0], &hostname, hostname_len);
hostname[hostname_len - 1] = '\0';
must_read(socks[0], &servname_len, sizeof(size_t));
- if (servname_len == 0 || servname_len > sizeof(servname))
+ if (servname_len == 0 ||
+ servname_len > sizeof(servname))
_exit(1);
must_read(socks[0], &servname, servname_len);
servname[servname_len - 1] = '\0';
/* Name/service to address translation. Response is placed into addr, and
* the length is returned (zero on error) */
int
-priv_gethostserv(char *host, char *serv, struct sockaddr *addr,
+priv_getaddrinfo(char *host, char *serv, struct sockaddr *addr,
size_t addr_len)
{
char hostcpy[MAXHOSTNAMELEN], servcpy[MAXHOSTNAMELEN];
errx(1, "%s: overflow attempt in servname", __func__);
servname_len = strlen(servcpy) + 1;
- cmd = PRIV_GETHOSTSERV;
+ cmd = PRIV_GETADDRINFO;
must_write(priv_fd, &cmd, sizeof(int));
must_write(priv_fd, &hostname_len, sizeof(size_t));
must_write(priv_fd, hostcpy, hostname_len);
/* Check there was no error (indicated by a return of 0) */
if (!ret_len)
- return 0;
+ return (-1);
/* Make sure we aren't overflowing the passed in buffer */
if (addr_len < ret_len)
memset(addr, '\0', addr_len);
must_read(priv_fd, addr, ret_len);
- return ret_len;
+ return (0);
}
/* Reverse address resolution; response is placed into res, and length of
-/* $OpenBSD: syslogd.c,v 1.112 2014/08/19 00:24:00 bluhm Exp $ */
+/* $OpenBSD: syslogd.c,v 1.113 2014/08/20 19:16:27 bluhm Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
struct filed *
cfline(char *line, char *prog)
{
- int i, pri, addr_len;
+ int i, pri;
size_t rb_len;
char *bp, *p, *q, *cp;
char buf[MAXLINE], ebuf[100];
logerror(ebuf);
break;
}
- addr_len = priv_gethostserv(f->f_un.f_forw.f_hname,
+ if (priv_getaddrinfo(f->f_un.f_forw.f_hname,
cp == NULL ? "syslog" : cp,
- (struct sockaddr*)&f->f_un.f_forw.f_addr,
- sizeof(f->f_un.f_forw.f_addr));
- if (addr_len < 1) {
+ (struct sockaddr *)&f->f_un.f_forw.f_addr,
+ sizeof(f->f_un.f_forw.f_addr)) != 0) {
snprintf(ebuf, sizeof(ebuf), "bad hostname \"%s\"", p);
logerror(ebuf);
break;