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

Rename priv_gethostserv() to priv_getaddrinfo() as this is what the

function does.  Change the return code semantics to match getaddrinfo(3).
OK deraadt@
This commit is contained in:
bluhm 2014-08-20 19:16:27 +00:00
parent c7c87c30b3
commit 2fa726a750
3 changed files with 18 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $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>
@ -67,7 +67,7 @@ enum cmd_types {
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 */
};
@ -289,17 +289,19 @@ priv_init(char *conf, int numeric, int lockfd, int nullfd, char *argv[])
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';
@ -657,7 +659,7 @@ priv_config_parse_done(void)
/* 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];
@ -674,7 +676,7 @@ priv_gethostserv(char *host, char *serv, struct sockaddr *addr,
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);
@ -686,7 +688,7 @@ priv_gethostserv(char *host, char *serv, struct sockaddr *addr,
/* 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)
@ -696,7 +698,7 @@ priv_gethostserv(char *host, char *serv, struct sockaddr *addr,
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

View File

@ -1,4 +1,4 @@
/* $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
@ -1427,7 +1427,7 @@ find_dup(struct filed *f)
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];
@ -1538,11 +1538,10 @@ cfline(char *line, char *prog)
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;

View File

@ -26,7 +26,7 @@ FILE *priv_open_utmp(void);
FILE *priv_open_config(void);
void priv_config_parse_done(void);
int priv_config_modified(void);
int priv_gethostserv(char *, char *, struct sockaddr *, size_t);
int priv_getaddrinfo(char *, char *, struct sockaddr *, size_t);
int priv_gethostbyaddr(char *, int, int, char *, size_t);
/* Terminal message */