From 88de69e80f77a8ad79a1a03534b346f1a8d48ed6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 7 Jan 2005 21:17:18 +0000 Subject: * Solaris 2.8 compat * C++ compat git-svn-id: file:///home/lennart/svn/public/libasyncns/trunk@11 cc0fb855-19ed-0310-866e-8c1d96e4abae --- libasyncns/asyncns.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'libasyncns/asyncns.c') diff --git a/libasyncns/asyncns.c b/libasyncns/asyncns.c index fd74133..6976256 100644 --- a/libasyncns/asyncns.c +++ b/libasyncns/asyncns.c @@ -121,6 +121,27 @@ typedef struct nameinfo_response { int ret; } nameinfo_response_t; +#ifndef HAVE_STRNDUP + +static char *strndup(const char *s, size_t l) { + size_t a; + char *n; + + a = strlen(s); + if (a > l) + a = l; + + if (!(n = malloc(a+1))) + return NULL; + + strncpy(n, s, a); + n[a] = 0; + + return n; +} + +#endif + static int fd_nonblock(int fd) { int i; assert(fd >= 0); @@ -301,7 +322,7 @@ static int worker(int in_fd, int out_fd) { #ifdef HAVE_SETRESUID setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid); #elif HAVE_SETREUID - setuid(pw->pw_uid, pw->pw_uid); + setreuid(pw->pw_uid, pw->pw_uid); #else setuid(pw->pw_uid); seteuid(pw->pw_uid); @@ -487,7 +508,7 @@ static void *unserialize_addrinfo(void *p, struct addrinfo **ret_ai, size_t *len struct addrinfo *ai; assert(p); assert(ret_ai); - assert(index); + assert(length); if (*length < sizeof(addrinfo_serialization_t)) return NULL; -- cgit