aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2015-01-12 07:24:01 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2015-01-12 07:24:01 +0000
commit54dd3272da3f4a5fda7dd6ac359b7cf68e21a796 (patch)
tree2e005d0e12c15ac2fb234260204fe1baeb3c8bee /services
parent3ff5baf8cb6770d63f234c261e9af15848bb939c (diff)
downloadsrc-54dd3272da3f4a5fda7dd6ac359b7cf68e21a796.tar.gz
src-54dd3272da3f4a5fda7dd6ac359b7cf68e21a796.zip
Merge upstream version of the local socket patch (upstream svn revisions
3304 through 3309).
Notes
Notes: svn path=/vendor/unbound/dist/; revision=277045
Diffstat (limited to 'services')
-rw-r--r--services/listen_dnsport.c13
-rw-r--r--services/listen_dnsport.h2
2 files changed, 10 insertions, 5 deletions
diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c
index 69c68b2807ff..0ce0a6b7b175 100644
--- a/services/listen_dnsport.c
+++ b/services/listen_dnsport.c
@@ -576,15 +576,19 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto,
}
int
-create_local_accept_sock(char *path, int* noproto)
+create_local_accept_sock(const char *path, int* noproto)
{
#ifdef HAVE_SYS_UN_H
int s;
struct sockaddr_un sun;
- sun.sun_len = sizeof(sun);
+#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+ /* this member exists on BSDs, not Linux */
+ sun.sun_len = (sa_family_t)sizeof(sun);
+#endif
sun.sun_family = AF_LOCAL;
- strlcpy(sun.sun_path, path, 104);
+ /* length is 92-108, 104 on FreeBSD */
+ (void)strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
if ((s = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1) {
log_err("Cannot create local socket %s (%s)",
@@ -600,7 +604,7 @@ create_local_accept_sock(char *path, int* noproto)
}
if (bind(s, (struct sockaddr *)&sun,
- sizeof(struct sockaddr_un)) == -1) {
+ (socklen_t)sizeof(struct sockaddr_un)) == -1) {
log_err("Cannot bind local socket %s (%s)",
path, strerror(errno));
return -1;
@@ -616,6 +620,7 @@ create_local_accept_sock(char *path, int* noproto)
return -1;
}
+ (void)noproto; /*unused*/
return s;
#else
log_err("Local sockets are not supported");
diff --git a/services/listen_dnsport.h b/services/listen_dnsport.h
index 0513b5d6c01b..e9883a8f4f97 100644
--- a/services/listen_dnsport.h
+++ b/services/listen_dnsport.h
@@ -214,6 +214,6 @@ int create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto,
* are not supported.
* @return: the socket. -1 on error.
*/
-int create_local_accept_sock(char* path, int* noproto);
+int create_local_accept_sock(const char* path, int* noproto);
#endif /* LISTEN_DNSPORT_H */