[haiku-commits] haiku: hrev49335 - in src/kits/network/netresolv: isc . resolv bsd inet

  • From: waddlesplash@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 29 Jun 2015 17:38:35 +0200 (CEST)

hrev49335 adds 7 changesets to branch 'master'
old head: ffc3c6172b883af00e9ddc1bf79a55ab55abc540
new head: b75bd04b4a137dd38103656de960cf0afca01a3f
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=b75bd04b4a13+%5Effc3c6172b88

----------------------------------------------------------------------------

f1b36c905085: netresolv/inet: Merge remaining patches from 2013 to current HEAD.

Commits merged from the semi-official Git mirror of NetBSD
trunk (https://github.com/IIJ-NetBSD/netbsd-src/ - inet
is in the tree at lib/libc/inet/).

Commit authors/messages in chronological order follow:
---------------------------------------
From: christos <christos@xxxxxxxxxx>
Date: Mon, 10 Feb 2014 16:29:30 +0000
Subject: PR/48585: Henning Petersen: Always set errno when returning NULL.

From: christos <christos@xxxxxxxxxx>
Date: Mon, 10 Feb 2014 16:30:54 +0000
Subject: remove unneeded code, and kill parens from return

24a60d9b9a72: netresolv/resolv: Merge remaining patches from 2013 to current
HEAD.

Commits merged from the semi-official Git mirror of NetBSD
trunk (https://github.com/IIJ-NetBSD/netbsd-src/ - NetResolv
is in the tree at lib/libc/netresolv/).

Commit authors/messages in chronological order follow:
---------------------------------------
From: wiz <wiz@xxxxxxxxxx>
Date: Mon, 9 Dec 2013 09:35:17 +0000
Subject: Fix typo ("then" instead of "than")

From: christos <christos@xxxxxxxxxx>
Date: Tue, 16 Sep 2014 01:30:00 +0000
Subject: close on exec hostaliases

From: christos <christos@xxxxxxxxxx>
Date: Tue, 11 Nov 2014 03:29:24 +0000
Subject: PR/48475: YAMAGUCHI Takanori: EDNS option broken with
unbound. struct querybuf in net/gethnamaddr.c defines MAXPACKET to 64K. This
in turn gets passed down until it reached res_nopt(..., answer, anslen),
where
the size of the buffer must fit in 16 bits. Unfortunately we end up
being one more than the max so we end up sending a 0 as the size and
unbound does not like that. Instead we clip now to 64K - 1, and everyone
is happy.
XXX: Pullup to 7.

From: christos <christos@xxxxxxxxxx>
Date: Tue, 24 Feb 2015 17:57:08 +0000
Subject: belated removal of the advertising clause.

08336907db2b: netresolv: Get rid of BSD strsep compat code.

We already have this in our libbsd.

cd88c756f30c: netresolv: remove nonexistent directory from Jamfile.

4ae91d30cb77: netresolv/isc: get rid of duplicate base64.c.

3cc9802e896c: netresolv/COPYRIGHT: Add BSD license, as it's in some of the
sources.

b75bd04b4a13: netresolv: Add a quick document on how to synchronize with NetBSD.

[ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

13 files changed, 96 insertions(+), 480 deletions(-)
src/kits/network/netresolv/COPYRIGHT | 28 +-
.../netresolv/HowTo-Synchronize_with_NetBSD.md | 30 ++
src/kits/network/netresolv/Jamfile | 11 +-
src/kits/network/netresolv/bsd/strsep.c | 88 -----
src/kits/network/netresolv/inet/inet_ntop.c | 41 ++-
src/kits/network/netresolv/isc/base64.c | 322 -------------------
src/kits/network/netresolv/resolv/herror.c | 8 +-
src/kits/network/netresolv/resolv/res_comp.c | 8 +-
src/kits/network/netresolv/resolv/res_debug.c | 8 +-
src/kits/network/netresolv/resolv/res_init.c | 4 +-
src/kits/network/netresolv/resolv/res_mkquery.c | 12 +-
src/kits/network/netresolv/resolv/res_query.c | 10 +-
src/kits/network/netresolv/resolv/res_send.c | 6 +-

############################################################################

Commit: f1b36c9050858a6bcf626904710d4181726746f6
URL: http://cgit.haiku-os.org/haiku/commit/?id=f1b36c905085
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jun 29 13:49:45 2015 UTC

netresolv/inet: Merge remaining patches from 2013 to current HEAD.

Commits merged from the semi-official Git mirror of NetBSD
trunk (https://github.com/IIJ-NetBSD/netbsd-src/ - inet
is in the tree at lib/libc/inet/).

Commit authors/messages in chronological order follow:
---------------------------------------
From: christos <christos@xxxxxxxxxx>
Date: Mon, 10 Feb 2014 16:29:30 +0000
Subject: PR/48585: Henning Petersen: Always set errno when returning NULL.

From: christos <christos@xxxxxxxxxx>
Date: Mon, 10 Feb 2014 16:30:54 +0000
Subject: remove unneeded code, and kill parens from return

----------------------------------------------------------------------------

diff --git a/src/kits/network/netresolv/inet/inet_ntop.c
b/src/kits/network/netresolv/inet/inet_ntop.c
index aba863a..8a0e8c1 100644
--- a/src/kits/network/netresolv/inet/inet_ntop.c
+++ b/src/kits/network/netresolv/inet/inet_ntop.c
@@ -1,4 +1,4 @@
-/* $NetBSD: inet_ntop.c,v 1.9 2012/03/20 17:08:13 matt Exp $ */
+/* $NetBSD: inet_ntop.c,v 1.11 2014/02/10 16:30:54 christos Exp $ */

/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -22,7 +22,7 @@
#if 0
static const char rcsid[] = "Id: inet_ntop.c,v 1.5 2005/11/03 22:59:52 marka
Exp";
#else
-__RCSID("$NetBSD: inet_ntop.c,v 1.9 2012/03/20 17:08:13 matt Exp $");
+__RCSID("$NetBSD: inet_ntop.c,v 1.11 2014/02/10 16:30:54 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */

@@ -69,12 +69,12 @@ inet_ntop(int af, const void *src, char *dst, socklen_t
size)

switch (af) {
case AF_INET:
- return (inet_ntop4(src, dst, size));
+ return inet_ntop4(src, dst, size);
case AF_INET6:
- return (inet_ntop6(src, dst, size));
+ return inet_ntop6(src, dst, size);
default:
errno = EAFNOSUPPORT;
- return (NULL);
+ return NULL;
}
/* NOTREACHED */
}
@@ -101,12 +101,10 @@ inet_ntop4(const u_char *src, char *dst, socklen_t size)

l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u",
src[0], src[1], src[2], src[3]);
- if (l <= 0 || (socklen_t) l >= size) {
- errno = ENOSPC;
- return (NULL);
- }
+ if (l <= 0 || (socklen_t) l >= size)
+ return NULL;
strlcpy(dst, tmp, size);
- return (dst);
+ return dst;
}

/* const char *
@@ -184,7 +182,7 @@ inet_ntop6(const u_char *src, char *dst, socklen_t size)
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0) {
if (tp + 1 >= ep)
- return (NULL);
+ goto out;
*tp++ = ':';
}
/* Is this address an encapsulated IPv4? */
@@ -192,36 +190,37 @@ inet_ntop6(const u_char *src, char *dst, socklen_t size)
(best.len == 6 ||
(best.len == 7 && words[7] != 0x0001) ||
(best.len == 5 && words[5] == 0xffff))) {
- if (!inet_ntop4(src+12, tp, (socklen_t)(ep - tp)))
- return (NULL);
+ if (!inet_ntop4(src + 12, tp, (socklen_t)(ep - tp)))
+ goto out;
tp += strlen(tp);
break;
}
advance = snprintf(tp, (size_t)(ep - tp), "%x", words[i]);
if (advance <= 0 || advance >= ep - tp)
- return (NULL);
+ goto out;
tp += advance;
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ)) {
if (tp + 1 >= ep)
- return (NULL);
+ goto out;
*tp++ = ':';
}
if (tp + 1 >= ep)
- return (NULL);
+ goto out;
*tp++ = '\0';

/*
* Check for overflow, copy, and we're done.
*/
- if ((size_t)(tp - tmp) > size) {
- errno = ENOSPC;
- return (NULL);
- }
+ if ((size_t)(tp - tmp) > size)
+ goto out;
strlcpy(dst, tmp, size);
- return (dst);
+ return dst;
+out:
+ errno = ENOSPC;
+ return NULL;
}

#undef inet_ntop

############################################################################

Commit: 24a60d9b9a72d248a209ee6a9ee322004d8936b2
URL: http://cgit.haiku-os.org/haiku/commit/?id=24a60d9b9a72
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jun 29 00:48:36 2015 UTC

netresolv/resolv: Merge remaining patches from 2013 to current HEAD.

Commits merged from the semi-official Git mirror of NetBSD
trunk (https://github.com/IIJ-NetBSD/netbsd-src/ - NetResolv
is in the tree at lib/libc/netresolv/).

Commit authors/messages in chronological order follow:
---------------------------------------
From: wiz <wiz@xxxxxxxxxx>
Date: Mon, 9 Dec 2013 09:35:17 +0000
Subject: Fix typo ("then" instead of "than")

From: christos <christos@xxxxxxxxxx>
Date: Tue, 16 Sep 2014 01:30:00 +0000
Subject: close on exec hostaliases

From: christos <christos@xxxxxxxxxx>
Date: Tue, 11 Nov 2014 03:29:24 +0000
Subject: PR/48475: YAMAGUCHI Takanori: EDNS option broken with
unbound. struct querybuf in net/gethnamaddr.c defines MAXPACKET to 64K. This
in turn gets passed down until it reached res_nopt(..., answer, anslen), where
the size of the buffer must fit in 16 bits. Unfortunately we end up
being one more than the max so we end up sending a 0 as the size and
unbound does not like that. Instead we clip now to 64K - 1, and everyone
is happy.
XXX: Pullup to 7.

From: christos <christos@xxxxxxxxxx>
Date: Tue, 24 Feb 2015 17:57:08 +0000
Subject: belated removal of the advertising clause.

----------------------------------------------------------------------------

diff --git a/src/kits/network/netresolv/resolv/herror.c
b/src/kits/network/netresolv/resolv/herror.c
index bd6255d..58c2b8a 100644
--- a/src/kits/network/netresolv/resolv/herror.c
+++ b/src/kits/network/netresolv/resolv/herror.c
@@ -1,4 +1,4 @@
-/* $NetBSD: herror.c,v 1.9 2012/03/13 21:13:43 christos Exp $ */
+/* $NetBSD: herror.c,v 1.10 2015/02/24 17:56:20 christos Exp $ */

/*
* Copyright (c) 1987, 1993
@@ -12,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/src/kits/network/netresolv/resolv/res_comp.c
b/src/kits/network/netresolv/resolv/res_comp.c
index 4557ac1..9c32acf 100644
--- a/src/kits/network/netresolv/resolv/res_comp.c
+++ b/src/kits/network/netresolv/resolv/res_comp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: res_comp.c,v 1.12 2012/03/13 21:13:43 christos Exp $ */
+/* $NetBSD: res_comp.c,v 1.13 2015/02/24 17:56:20 christos Exp $ */

/*
* Copyright (c) 1985, 1993
@@ -12,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/src/kits/network/netresolv/resolv/res_debug.c
b/src/kits/network/netresolv/resolv/res_debug.c
index 7d096bc..63a14c1 100644
--- a/src/kits/network/netresolv/resolv/res_debug.c
+++ b/src/kits/network/netresolv/resolv/res_debug.c
@@ -1,4 +1,4 @@
-/* $NetBSD: res_debug.c,v 1.13 2012/06/25 22:32:45 abs Exp $ */
+/* $NetBSD: res_debug.c,v 1.14 2015/02/24 17:56:20 christos Exp $ */

/*
* Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium,
Inc. ("ISC")
@@ -29,11 +29,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/src/kits/network/netresolv/resolv/res_init.c
b/src/kits/network/netresolv/resolv/res_init.c
index 0e218f6..74c665a 100644
--- a/src/kits/network/netresolv/resolv/res_init.c
+++ b/src/kits/network/netresolv/resolv/res_init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: res_init.c,v 1.26 2012/09/09 18:04:26 christos Exp $ */
+/* $NetBSD: res_init.c,v 1.30 2015/02/24 17:56:20 christos Exp $ */

/*
* Copyright (c) 1985, 1989, 1993
@@ -240,7 +240,7 @@ __res_vinit(res_state statp, int preinit) {
* Examples and applications exist which do not check
* our return code. Furthermore several applications
* simply call us to get the systems domainname. So
- * rather then immediately fail here we store the
+ * rather than immediately fail here we store the
* failure, which is returned later, in h_errno. And
* prevent the collection of 'nameserver' information
* by setting maxns to 0. Thus applications that fail
diff --git a/src/kits/network/netresolv/resolv/res_mkquery.c
b/src/kits/network/netresolv/resolv/res_mkquery.c
index 6e7b394..743a22b 100644
--- a/src/kits/network/netresolv/resolv/res_mkquery.c
+++ b/src/kits/network/netresolv/resolv/res_mkquery.c
@@ -1,4 +1,4 @@
-/* $NetBSD: res_mkquery.c,v 1.13 2012/03/13 21:13:43 christos Exp $
*/
+/* $NetBSD: res_mkquery.c,v 1.15 2015/02/24 17:56:20 christos Exp $
*/

/*
* Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc.
("ISC")
@@ -29,11 +29,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -235,7 +231,9 @@ res_nopt(res_state statp,
*cp++ = 0; /*%< "." */
ns_put16(ns_t_opt, cp); /*%< TYPE */
cp += INT16SZ;
- ns_put16(anslen & 0xffff, cp); /*%< CLASS = UDP payload size */
+ if (anslen > 0xffff)
+ anslen = 0xffff;
+ ns_put16(anslen, cp); /*%< CLASS = UDP payload size */
cp += INT16SZ;
*cp++ = NOERROR; /*%< extended RCODE */
*cp++ = 0; /*%< EDNS version */
diff --git a/src/kits/network/netresolv/resolv/res_query.c
b/src/kits/network/netresolv/resolv/res_query.c
index 0590b93..b60bc4c 100644
--- a/src/kits/network/netresolv/resolv/res_query.c
+++ b/src/kits/network/netresolv/resolv/res_query.c
@@ -1,4 +1,4 @@
-/* $NetBSD: res_query.c,v 1.14 2012/03/13 21:13:44 christos Exp $ */
+/* $NetBSD: res_query.c,v 1.16 2015/02/24 17:56:20 christos Exp $ */

/*
* Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc.
("ISC")
@@ -29,11 +29,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -410,7 +406,7 @@ res_hostalias(const res_state statp, const char *name, char
*dst, size_t siz) {
return (NULL);

file = getenv("HOSTALIASES");
- if (file == NULL || (fp = fopen(file, "r")) == NULL)
+ if (file == NULL || (fp = fopen(file, "re")) == NULL)
return (NULL);
buf[sizeof(buf) - 1] = '\0';
while (fgets(buf, (int)sizeof(buf), fp)) {
diff --git a/src/kits/network/netresolv/resolv/res_send.c
b/src/kits/network/netresolv/resolv/res_send.c
index 5c591c0..2109413 100644
--- a/src/kits/network/netresolv/resolv/res_send.c
+++ b/src/kits/network/netresolv/resolv/res_send.c
@@ -27,11 +27,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*

############################################################################

Commit: 08336907db2b2e36ed521a5202d89d6decdee1fb
URL: http://cgit.haiku-os.org/haiku/commit/?id=08336907db2b
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jun 29 15:14:49 2015 UTC

netresolv: Get rid of BSD strsep compat code.

We already have this in our libbsd.

----------------------------------------------------------------------------

diff --git a/src/kits/network/netresolv/Jamfile
b/src/kits/network/netresolv/Jamfile
index adcbfdf..cca6418 100644
--- a/src/kits/network/netresolv/Jamfile
+++ b/src/kits/network/netresolv/Jamfile
@@ -14,8 +14,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
# private sources for this port
SEARCH_SOURCE += [ FDirName $(SUBDIR) src ] ;

- # BIND sources
- SEARCH_SOURCE += [ FDirName $(SUBDIR) bsd ] ;
+ # NetResolv sources
SEARCH_SOURCE += [ FDirName $(SUBDIR) dst ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) inet ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) irs ] ;
@@ -120,9 +119,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
res_query.c
res_send.c
res_state.c
-
- # private functions
- strsep.c
;
}
}
diff --git a/src/kits/network/netresolv/bsd/strsep.c
b/src/kits/network/netresolv/bsd/strsep.c
deleted file mode 100644
index c7969f0..0000000
--- a/src/kits/network/netresolv/bsd/strsep.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "strsep.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: strsep.c,v 1.2 2005/04/27 04:56:12 sra Exp
$";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "port_before.h"
-#include <sys/cdefs.h>
-#include <string.h>
-#include <stdio.h>
-#include "port_after.h"
-
-#ifndef NEED_STRSEP
-int __strsep_unneeded__;
-#else
-
-/*%
- * Get next token from string *stringp, where tokens are possibly-empty
- * strings separated by characters from delim.
- *
- * Writes NULs into the string at *stringp to end tokens.
- * delim need not remain constant from call to call.
- * On return, *stringp points past the last NUL written (if there might
- * be further tokens), or is NULL (if there are definitely no more tokens).
- *
- * If *stringp is NULL, strsep returns NULL.
- */
-char *
-strsep(char **stringp, const char *delim) {
- char *s;
- const char *spanp;
- int c, sc;
- char *tok;
-
- if ((s = *stringp) == NULL)
- return (NULL);
- for (tok = s;;) {
- c = *s++;
- spanp = delim;
- do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
- s = NULL;
- else
- s[-1] = 0;
- *stringp = s;
- return (tok);
- }
- } while (sc != 0);
- }
- /* NOTREACHED */
-}
-
-#endif /*NEED_STRSEP*/
-
-/*! \file */

############################################################################

Commit: cd88c756f30c55a5a46383186daf66e81418fae1
URL: http://cgit.haiku-os.org/haiku/commit/?id=cd88c756f30c
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jun 29 15:18:55 2015 UTC

netresolv: remove nonexistent directory from Jamfile.

----------------------------------------------------------------------------

diff --git a/src/kits/network/netresolv/Jamfile
b/src/kits/network/netresolv/Jamfile
index cca6418..d9b9048 100644
--- a/src/kits/network/netresolv/Jamfile
+++ b/src/kits/network/netresolv/Jamfile
@@ -11,9 +11,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ]
: true ;
SubDirSysHdrs $(SUBDIR) ;

- # private sources for this port
- SEARCH_SOURCE += [ FDirName $(SUBDIR) src ] ;
-
# NetResolv sources
SEARCH_SOURCE += [ FDirName $(SUBDIR) dst ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) inet ] ;

############################################################################

Commit: 4ae91d30cb7775020622e8b26a036feb24dd85df
URL: http://cgit.haiku-os.org/haiku/commit/?id=4ae91d30cb77
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jun 29 15:22:34 2015 UTC

netresolv/isc: get rid of duplicate base64.c.

----------------------------------------------------------------------------

diff --git a/src/kits/network/netresolv/Jamfile
b/src/kits/network/netresolv/Jamfile
index d9b9048..99734d3 100644
--- a/src/kits/network/netresolv/Jamfile
+++ b/src/kits/network/netresolv/Jamfile
@@ -52,6 +52,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
nsap_addr.c

# irs
+ base64.c
getaddrinfo.c
gethnamaddr.c
getnameinfo.c
@@ -78,7 +79,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {

# isc
assertions.c
- base64.c
bitncmp.c
ctl_clnt.c
ctl_p.c
diff --git a/src/kits/network/netresolv/isc/base64.c
b/src/kits/network/netresolv/isc/base64.c
deleted file mode 100644
index 60b20bc..0000000
--- a/src/kits/network/netresolv/isc/base64.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Portions Copyright (c) 1995 by International Business Machines, Inc.
- *
- * International Business Machines, Inc. (hereinafter called IBM) grants
- * permission under its copyrights to use, copy, modify, and distribute this
- * Software with or without fee, provided that the above copyright notice and
- * all paragraphs of this notice appear in all copies, and that the name of IBM
- * not be used in connection with the marketing of any product incorporating
- * the Software or modifications thereof, without specific, written prior
- * permission.
- *
- * To the extent it has a right to do so, IBM grants an immunity from suit
- * under its patents, if any, for the use, sale or manufacture of products to
- * the extent that such products are used for performing Domain Name System
- * dynamic updates in TCP/IP networks by means of the Software. No immunity is
- * granted for any product per se or for any other function of any product.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-#if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: base64.c,v 1.4 2005/04/27 04:56:34 sra Exp
$";
-#endif /* not lint */
-
-#include "port_before.h"
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
-#include <ctype.h>
-#include <resolv.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "port_after.h"
-
-#define Assert(Cond) if (!(Cond)) abort()
-
-static const char Base64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-static const char Pad64 = '=';
-
-/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
- The following encoding technique is taken from RFC1521 by Borenstein
- and Freed. It is reproduced here in a slightly edited form for
- convenience.
-
- A 65-character subset of US-ASCII is used, enabling 6 bits to be
- represented per printable character. (The extra 65th character, "=",
- is used to signify a special processing function.)
-
- The encoding process represents 24-bit groups of input bits as output
- strings of 4 encoded characters. Proceeding from left to right, a
- 24-bit input group is formed by concatenating 3 8-bit input groups.
- These 24 bits are then treated as 4 concatenated 6-bit groups, each
- of which is translated into a single digit in the base64 alphabet.
-
- Each 6-bit group is used as an index into an array of 64 printable
- characters. The character referenced by the index is placed in the
- output string.
-
- Table 1: The Base64 Alphabet
-
- Value Encoding Value Encoding Value Encoding Value Encoding
- 0 A 17 R 34 i 51 z
- 1 B 18 S 35 j 52 0
- 2 C 19 T 36 k 53 1
- 3 D 20 U 37 l 54 2
- 4 E 21 V 38 m 55 3
- 5 F 22 W 39 n 56 4
- 6 G 23 X 40 o 57 5
- 7 H 24 Y 41 p 58 6
- 8 I 25 Z 42 q 59 7
- 9 J 26 a 43 r 60 8
- 10 K 27 b 44 s 61 9
- 11 L 28 c 45 t 62 +
- 12 M 29 d 46 u 63 /
- 13 N 30 e 47 v
- 14 O 31 f 48 w (pad) =
- 15 P 32 g 49 x
- 16 Q 33 h 50 y
-
- Special processing is performed if fewer than 24 bits are available
- at the end of the data being encoded. A full encoding quantum is
- always completed at the end of a quantity. When fewer than 24 input
- bits are available in an input group, zero bits are added (on the
- right) to form an integral number of 6-bit groups. Padding at the
- end of the data is performed using the '=' character.
-
- Since all base64 input is an integral number of octets, only the
- -------------------------------------------------

- following cases can arise:
-
- (1) the final quantum of encoding input is an integral
- multiple of 24 bits; here, the final unit of encoded
- output will be an integral multiple of 4 characters
- with no "=" padding,
- (2) the final quantum of encoding input is exactly 8 bits;
- here, the final unit of encoded output will be two
- characters followed by two "=" padding characters, or
- (3) the final quantum of encoding input is exactly 16 bits;
- here, the final unit of encoded output will be three
- characters followed by one "=" padding character.
- */
-
-int
-b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) {
- size_t datalength = 0;
- u_char input[3];
- u_char output[4];
- size_t i;
-
- while (2U < srclength) {
- input[0] = *src++;
- input[1] = *src++;
- input[2] = *src++;
- srclength -= 3;
-
- output[0] = input[0] >> 2;
- output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
- output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
- output[3] = input[2] & 0x3f;
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
- Assert(output[3] < 64);
-
- if (datalength + 4 > targsize)
- return (-1);
- target[datalength++] = Base64[output[0]];
- target[datalength++] = Base64[output[1]];
- target[datalength++] = Base64[output[2]];
- target[datalength++] = Base64[output[3]];
- }
-
- /* Now we worry about padding. */
- if (0U != srclength) {
- /* Get what's left. */
- input[0] = input[1] = input[2] = '\0';
- for (i = 0; i < srclength; i++)
- input[i] = *src++;
-
- output[0] = input[0] >> 2;
- output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
- output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
-
- if (datalength + 4 > targsize)
- return (-1);
- target[datalength++] = Base64[output[0]];
- target[datalength++] = Base64[output[1]];
- if (srclength == 1U)
- target[datalength++] = Pad64;
- else
- target[datalength++] = Base64[output[2]];
- target[datalength++] = Pad64;
- }
- if (datalength >= targsize)
- return (-1);
- target[datalength] = '\0'; /*%< Returned value doesn't count \\0.
*/
- return (datalength);
-}
-
-/* skips all whitespace anywhere.
- converts characters, four at a time, starting at (or after)
- src from base - 64 numbers into three 8 bit bytes in the target area.
- it returns the number of data bytes stored at the target, or -1 on error.
- */
-
-int
-b64_pton(src, target, targsize)
- char const *src;
- u_char *target;
- size_t targsize;
-{
- int tarindex, state, ch;
- char *pos;
-
- state = 0;
- tarindex = 0;
-
- while ((ch = *src++) != '\0') {
- if (isspace(ch)) /*%< Skip whitespace anywhere. */
- continue;
-
- if (ch == Pad64)
- break;
-
- pos = strchr(Base64, ch);
- if (pos == 0) /*%< A non-base64 character. */
- return (-1);
-
- switch (state) {
- case 0:
- if (target) {
- if ((size_t)tarindex >= targsize)
- return (-1);
- target[tarindex] = (pos - Base64) << 2;
- }
- state = 1;
- break;
- case 1:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64) >> 4;
- target[tarindex+1] = ((pos - Base64) & 0x0f)
- << 4 ;
- }
- tarindex++;
- state = 2;
- break;
- case 2:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64) >> 2;
- target[tarindex+1] = ((pos - Base64) & 0x03)
- << 6;
- }
- tarindex++;
- state = 3;
- break;
- case 3:
- if (target) {
- if ((size_t)tarindex >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64);
- }
- tarindex++;
- state = 0;
- break;
- default:
- abort();
- }
- }
-
- /*
- * We are done decoding Base-64 chars. Let's see if we ended
- * on a byte boundary, and/or with erroneous trailing characters.
- */
-
- if (ch == Pad64) { /*%< We got a pad char. */
- ch = *src++; /*%< Skip it, get next. */
- switch (state) {
- case 0: /*%< Invalid = in first position */
- case 1: /*%< Invalid = in second position */
- return (-1);
-
- case 2: /*%< Valid, means one byte of info */
- /* Skip any number of spaces. */
- for ((void)NULL; ch != '\0'; ch = *src++)
- if (!isspace(ch))
- break;
- /* Make sure there is another trailing = sign. */
- if (ch != Pad64)
- return (-1);
- ch = *src++; /*%< Skip the = */
- /* Fall through to "single trailing =" case. */
- /* FALLTHROUGH */
-
- case 3: /*%< Valid, means two bytes of info */
- /*
- * We know this char is an =. Is there anything but
- * whitespace after it?
- */
- for ((void)NULL; ch != '\0'; ch = *src++)
- if (!isspace(ch))
- return (-1);
-
- /*
- * Now make sure for cases 2 and 3 that the "extra"
- * bits that slopped past the last full byte were
- * zeros. If we don't check them, they become a
- * subliminal channel.
- */
- if (target && target[tarindex] != 0)
- return (-1);
- }
- } else {
- /*
- * We ended by seeing the end of the string. Make sure we
- * have no partial bytes lying around.
- */
- if (state != 0)
- return (-1);
- }
-
- return (tarindex);
-}
-
-/*! \file */

############################################################################

Commit: 3cc9802e896c7c6072a84c9911cd2d99bc8ed3d6
URL: http://cgit.haiku-os.org/haiku/commit/?id=3cc9802e896c
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jun 29 15:34:31 2015 UTC

netresolv/COPYRIGHT: Add BSD license, as it's in some of the sources.

----------------------------------------------------------------------------

diff --git a/src/kits/network/netresolv/COPYRIGHT
b/src/kits/network/netresolv/COPYRIGHT
index d85a7db..2ea0ea7 100644
--- a/src/kits/network/netresolv/COPYRIGHT
+++ b/src/kits/network/netresolv/COPYRIGHT
@@ -12,5 +12,31 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
+---------------------------------
+Copyright (c) 1985-1993 The Regents of the University of California. All rights
+ reserved.
+Copyright (c) 2009-2015 The NetBSD Project. All rights reserved.

-$Id: COPYRIGHT,v 1.3 2009/01/20 23:49:22 tbox Exp $
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.

############################################################################

Revision: hrev49335
Commit: b75bd04b4a137dd38103656de960cf0afca01a3f
URL: http://cgit.haiku-os.org/haiku/commit/?id=b75bd04b4a13
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jun 29 15:35:04 2015 UTC

netresolv: Add a quick document on how to synchronize with NetBSD.

----------------------------------------------------------------------------

diff --git a/src/kits/network/netresolv/HowTo-Synchronize_with_NetBSD.md
b/src/kits/network/netresolv/HowTo-Synchronize_with_NetBSD.md
new file mode 100644
index 0000000..f7af170
--- /dev/null
+++ b/src/kits/network/netresolv/HowTo-Synchronize_with_NetBSD.md
@@ -0,0 +1,30 @@
+How to Merge Patches from NetBSD Trunk
+============================================
+Using the NetBSD CVS is a pain, so instead, the preferred thing to do is to use
+[IIJ's Git mirror](https://github.com/IIJ-NetBSD/netbsd-src). The code here is
+in the tree at a few places:`inet` is at `lib/libc/inet`, irs is scattered
+across the tree, and `resolv` is at `lib/libc/resolv`.
+
+The preferable way to merge is to take the last commit merged from IIJ's mirror
+(can be found in the merging commit in Haiku, if the merger has done their work
+properly) and check all commits since then to see if they apply or not (some
+apply to documentation we don't have, etc.) Cherry-pick the ones that do, and
+download them as git-format-patch patches (by adding `.patch` onto the end of
the
+commit URL).
+
+To convert the patches to have the correct paths to the resolv/inet/etc. code,
use
+`sed`:
+```
+sed s%lib/libc/resolv%src/kits/network/netresolv/resolv%g -i *.patch
+```
+(You'll need to use similar commands for the `inet` and `irs` code.)
+
+Then apply the patches using `git apply --reject file.patch`. Git will spew a
lot of
+errors about files in the patch that aren't in the tree, and then it will warn
that
+some hunks are being rejected. Review the rejected hunks **VERY CAREFULLY**, as
+some code in Haiku's NetResolv is not in NetBSD's and vice versa, and so some
patches
+may not apply cleanly because of that. You might have to resort to merging
those
+hunks by hand, if they apply at all to Haiku's code.
+
+Commit the changes all at once, but list all the commits merged from NetBSD
+in the commit message (see previous merges for the style to follow).


Other related posts: