summaryrefslogtreecommitdiff
path: root/net/tnftp/files/libnetbsd
diff options
context:
space:
mode:
authorlukem <lukem@pkgsrc.org>2005-06-10 05:06:25 +0000
committerlukem <lukem@pkgsrc.org>2005-06-10 05:06:25 +0000
commit84c028ec5eb6984ce185aead606f4f858f8ffed2 (patch)
tree696ce1a24a0fad4694a3baa5d83bfc731dc80e09 /net/tnftp/files/libnetbsd
parentf6e9257fb31d458ec367d02c2ac0ce60e4f6b9a1 (diff)
downloadpkgsrc-84c028ec5eb6984ce185aead606f4f858f8ffed2.tar.gz
merge tnftp 20050610
Diffstat (limited to 'net/tnftp/files/libnetbsd')
-rw-r--r--net/tnftp/files/libnetbsd/Makefile.in10
-rw-r--r--net/tnftp/files/libnetbsd/ftpglob.h10
-rw-r--r--net/tnftp/files/libnetbsd/ftpvis.h15
-rw-r--r--net/tnftp/files/libnetbsd/getnameinfo.c14
-rw-r--r--net/tnftp/files/libnetbsd/glob.c22
-rw-r--r--net/tnftp/files/libnetbsd/inet_ntop.c96
-rw-r--r--net/tnftp/files/libnetbsd/inet_pton.c79
-rw-r--r--net/tnftp/files/libnetbsd/mkstemp.c18
-rw-r--r--net/tnftp/files/libnetbsd/sl_init.c11
-rw-r--r--net/tnftp/files/libnetbsd/strdup.c10
-rw-r--r--net/tnftp/files/libnetbsd/strlcat.c44
-rw-r--r--net/tnftp/files/libnetbsd/strlcpy.c37
-rw-r--r--net/tnftp/files/libnetbsd/strsep.c10
-rw-r--r--net/tnftp/files/libnetbsd/strtoll.c25
-rw-r--r--net/tnftp/files/libnetbsd/strunvis.c91
-rw-r--r--net/tnftp/files/libnetbsd/strvis.c388
-rw-r--r--net/tnftp/files/libnetbsd/usleep.c10
17 files changed, 546 insertions, 344 deletions
diff --git a/net/tnftp/files/libnetbsd/Makefile.in b/net/tnftp/files/libnetbsd/Makefile.in
index ee8661b3bf8..7cc3d64d5b2 100644
--- a/net/tnftp/files/libnetbsd/Makefile.in
+++ b/net/tnftp/files/libnetbsd/Makefile.in
@@ -1,4 +1,4 @@
-# NetBSD: Makefile.in,v 1.3 2005/05/11 01:01:56 lukem Exp
+# NetBSD: Makefile.in,v 1.5 2005/06/10 04:36:12 lukem Exp
#
srcdir = @srcdir@
@@ -6,7 +6,8 @@ VPATH = @srcdir@
SHELL = /bin/sh
CC = @CC@
-CFLAGS = -I${srcdir} -I${srcdir}/.. -I.. @INCLUDES@ @CFLAGS@
+CFLAGS = @CFLAGS@
+CPPFLAGS= -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CPPFLAGS@
AR = @AR@
RANLIB = @RANLIB@
@@ -22,6 +23,11 @@ ${LIB}: ${OBJS}
${AR} cr $@ ${OBJS}
${RANLIB} $@
+${OBJS}: ${srcdir}/../tnftp.h ../config.h
+
+.c.o:
+ ${CC} ${CFLAGS} ${CPPFLAGS} -c $<
+
install:
clean:
diff --git a/net/tnftp/files/libnetbsd/ftpglob.h b/net/tnftp/files/libnetbsd/ftpglob.h
index 5c59a6e5423..044dad5c22f 100644
--- a/net/tnftp/files/libnetbsd/ftpglob.h
+++ b/net/tnftp/files/libnetbsd/ftpglob.h
@@ -1,5 +1,5 @@
-/* NetBSD: ftpglob.h,v 1.2 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: glob.h,v 1.13 2001/03/16 21:02:42 christos Exp */
+/* NetBSD: ftpglob.h,v 1.3 2005/05/16 05:45:40 lukem Exp */
+/* from NetBSD: glob.h,v 1.19 2005/02/03 04:39:32 perry Exp */
/*
* Copyright (c) 1989, 1993
@@ -16,11 +16,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/net/tnftp/files/libnetbsd/ftpvis.h b/net/tnftp/files/libnetbsd/ftpvis.h
index c13a27f9f53..acb1b4e3bc2 100644
--- a/net/tnftp/files/libnetbsd/ftpvis.h
+++ b/net/tnftp/files/libnetbsd/ftpvis.h
@@ -1,5 +1,5 @@
-/* NetBSD: ftpvis.h,v 1.2 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: vis.h,v 1.10 1998/11/13 12:20:18 christos Exp */
+/* NetBSD: ftpvis.h,v 1.3 2005/05/16 13:25:48 lukem Exp */
+/* from NetBSD: vis.h,v 1.15 2005/02/03 04:39:32 perry Exp */
/*-
* Copyright (c) 1990, 1993
@@ -13,11 +13,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.
*
@@ -59,6 +55,7 @@
* other
*/
#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
+#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */
/*
* unvis return codes
@@ -75,9 +72,13 @@
#define UNVIS_END 1 /* no more characters */
char *vis(char *, int, int, int);
+char *svis(char *, int, int, int, const char *);
int strvis(char *, const char *, int);
+int strsvis(char *, const char *, int, const char *);
int strvisx(char *, const char *, size_t, int);
+int strsvisx(char *, const char *, size_t, int, const char *);
int strunvis(char *, const char *);
+int strunvisx(char *, const char *, int);
int unvis(char *, int, int *, int);
#endif /* !_VIS_H_ */
diff --git a/net/tnftp/files/libnetbsd/getnameinfo.c b/net/tnftp/files/libnetbsd/getnameinfo.c
index c49f7fc143b..897f4ce068e 100644
--- a/net/tnftp/files/libnetbsd/getnameinfo.c
+++ b/net/tnftp/files/libnetbsd/getnameinfo.c
@@ -1,4 +1,4 @@
-/* NetBSD: getnameinfo.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* NetBSD: getnameinfo.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
/* from ? */
/*
@@ -67,9 +67,9 @@ static struct afd {
};
struct sockinet {
- u_char si_len;
- u_char si_family;
- u_short si_port;
+ unsigned char si_len;
+ unsigned char si_family;
+ unsigned short si_port;
};
#ifdef INET6
@@ -87,13 +87,13 @@ static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int);
#define ENI_SALEN EAI_FAMILY
int
-getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
- size_t hostlen, char *serv, size_t servlen, int flags)
+getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *host, size_t hostlen, char *serv, size_t servlen, int flags)
{
struct afd *afd;
struct servent *sp;
struct hostent *hp;
- u_short port;
+ unsigned short port;
int family, i;
const char *addr;
unsigned int v4a;
diff --git a/net/tnftp/files/libnetbsd/glob.c b/net/tnftp/files/libnetbsd/glob.c
index 26ec800729f..c2635cb7841 100644
--- a/net/tnftp/files/libnetbsd/glob.c
+++ b/net/tnftp/files/libnetbsd/glob.c
@@ -1,5 +1,5 @@
-/* NetBSD: glob.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: __glob13.c,v 1.23 2001/09/18 16:37:26 christos Exp */
+/* NetBSD: glob.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
+/* from NetBSD: __glob13.c,v 1.25 2003/08/07 16:42:45 agc Exp */
/*
* Copyright (c) 1989, 1993
@@ -16,11 +16,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.
*
@@ -88,7 +84,7 @@
#define M_MASK 0xffff
#define M_ASCII 0x00ff
-typedef u_short Char;
+typedef unsigned short Char;
#else
@@ -137,11 +133,11 @@ int
glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
glob_t *pglob)
{
- const u_char *patnext;
+ const unsigned char *patnext;
int c;
Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
- patnext = (const u_char *) pattern;
+ patnext = (const unsigned char *) pattern;
if (!(flags & GLOB_APPEND)) {
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
@@ -616,7 +612,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathlim,
else
readdirfunc = (struct dirent *(*)(void *)) readdir;
while ((dp = (*readdirfunc)(dirp)) != NULL) {
- u_char *sc;
+ unsigned char *sc;
Char *dc;
/* Initial DOT must be matched literally. */
@@ -626,7 +622,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathlim,
* The resulting string contains EOS, so we can
* use the pathlim character, if it is the nul
*/
- for (sc = (u_char *) dp->d_name, dc = pathend;
+ for (sc = (unsigned char *) dp->d_name, dc = pathend;
dc <= pathlim && (*dc++ = *sc++) != EOS;)
continue;
@@ -806,7 +802,7 @@ g_opendir(Char *str, glob_t *pglob)
char buf[MAXPATHLEN];
if (!*str)
- (void)strcpy(buf, ".");
+ (void)strlcpy(buf, ".", sizeof(buf));
else {
if (g_Ctoc(str, buf, sizeof(buf)))
return NULL;
diff --git a/net/tnftp/files/libnetbsd/inet_ntop.c b/net/tnftp/files/libnetbsd/inet_ntop.c
index a7b27bd4ad7..ac2fde52109 100644
--- a/net/tnftp/files/libnetbsd/inet_ntop.c
+++ b/net/tnftp/files/libnetbsd/inet_ntop.c
@@ -1,20 +1,21 @@
-/* NetBSD: inet_ntop.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: inet_ntop.c,v 1.9 2000/01/22 22:19:16 mycroft Exp */
+/* NetBSD: inet_ntop.c,v 1.6 2005/06/01 11:48:49 lukem Exp */
+/* from NetBSD: inet_ntop.c,v 1.2 2004/05/20 23:12:33 christos Exp */
-/* Copyright (c) 1996 by Internet Software Consortium.
+/*
+ * 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM 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.
+ * 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.
*/
#include "tnftp.h"
@@ -23,18 +24,12 @@
#include <arpa/nameser.h>
#endif
-#ifndef IN6ADDRSZ
-#define IN6ADDRSZ 16
-#endif
-
-#ifndef INT16SZ
-#define INT16SZ 2
+#ifndef NS_IN6ADDRSZ
+#define NS_IN6ADDRSZ 16
#endif
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
-#else
-# define SPRINTF(x) ((size_t)sprintf x)
+#ifndef NS_INT16SZ
+#define NS_INT16SZ 2
#endif
/*
@@ -42,8 +37,8 @@
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
-static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
-static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
+static const char *inet_ntop4(const unsigned char *src, char *dst, socklen_t size);
+static const char *inet_ntop6(const unsigned char *src, char *dst, socklen_t size);
/* char *
* inet_ntop(af, src, dst, size)
@@ -54,7 +49,7 @@ static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
* Paul Vixie, 1996.
*/
const char *
-inet_ntop(int af, const void *src, char *dst, size_t size)
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
switch (af) {
@@ -78,21 +73,23 @@ inet_ntop(int af, const void *src, char *dst, size_t size)
* `dst' (as a const)
* notes:
* (1) uses no statics
- * (2) takes a u_char* not an in_addr as input
+ * (2) takes a unsigned char* not an in_addr as input
* author:
* Paul Vixie, 1996.
*/
static const char *
-inet_ntop4(const u_char *src, char *dst, size_t size)
+inet_ntop4(const unsigned char *src, char *dst, socklen_t size)
{
- static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
+ int l;
- if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > 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);
}
- strcpy(dst, tmp);
+ strlcpy(dst, tmp, size);
return (dst);
}
@@ -104,7 +101,7 @@ inet_ntop4(const u_char *src, char *dst, size_t size)
* Paul Vixie, 1996.
*/
static const char *
-inet_ntop6(const u_char *src, char *dst, size_t size)
+inet_ntop6(const unsigned char *src, char *dst, socklen_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
@@ -113,10 +110,12 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+ char *tp, *ep;
struct { int base, len; } best, cur;
- u_int words[IN6ADDRSZ / INT16SZ];
+ unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
+ int advance;
/*
* Preprocess:
@@ -124,11 +123,11 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof words);
- for (i = 0; i < IN6ADDRSZ; i++)
+ for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+ for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
@@ -153,7 +152,8 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Format the result.
*/
tp = tmp;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+ ep = tmp + sizeof(tmp);
+ for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
@@ -162,21 +162,35 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
- if (i != 0)
+ if (i != 0) {
+ if (tp + 1 >= ep)
+ return (NULL);
*tp++ = ':';
+ }
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
- if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
+ (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);
tp += strlen(tp);
break;
}
- tp += SPRINTF((tp, "%x", words[i]));
+ advance = snprintf(tp, (size_t)(ep - tp), "%x", words[i]);
+ if (advance <= 0 || advance >= ep - tp)
+ return (NULL);
+ tp += advance;
}
/* Was it a trailing run of 0x00's? */
- if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
+ if (best.base != -1 && (best.base + best.len) ==
+ (NS_IN6ADDRSZ / NS_INT16SZ)) {
+ if (tp + 1 >= ep)
+ return (NULL);
*tp++ = ':';
+ }
+ if (tp + 1 >= ep)
+ return (NULL);
*tp++ = '\0';
/*
@@ -186,7 +200,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
errno = ENOSPC;
return (NULL);
}
- strcpy(dst, tmp);
+ strlcpy(dst, tmp, size);
return (dst);
}
#endif
diff --git a/net/tnftp/files/libnetbsd/inet_pton.c b/net/tnftp/files/libnetbsd/inet_pton.c
index ea846b48e23..9072c48a405 100644
--- a/net/tnftp/files/libnetbsd/inet_pton.c
+++ b/net/tnftp/files/libnetbsd/inet_pton.c
@@ -1,20 +1,21 @@
-/* NetBSD: inet_pton.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: inet_pton.c,v 1.16 2000/02/07 18:51:02 itojun Exp */
+/* NetBSD: inet_pton.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
+/* from NetBSD: inet_pton.c,v 1.2 2004/05/20 23:12:33 christos Exp */
-/* Copyright (c) 1996 by Internet Software Consortium.
+/*
+ * 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM 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.
+ * 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.
*/
#include "tnftp.h"
@@ -23,8 +24,16 @@
#include <arpa/nameser.h>
#endif
-#ifndef INADDRSZ
-#define INADDRSZ 4
+#ifndef NS_INADDRSZ
+#define NS_INADDRSZ 4
+#endif
+
+#ifndef NS_IN6ADDRSZ
+#define NS_IN6ADDRSZ 16
+#endif
+
+#ifndef NS_INT16SZ
+#define NS_INT16SZ 2
#endif
/*
@@ -32,9 +41,9 @@
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
-static int inet_pton4(const char *src, u_char *dst, int pton);
+static int inet_pton4(const char *src, unsigned char *dst, int pton);
#ifdef INET6
-static int inet_pton6(const char *src, u_char *dst);
+static int inet_pton6(const char *src, unsigned char *dst);
#endif
/* int
@@ -78,14 +87,14 @@ inet_pton(int af, const char *src, void *dst)
* Paul Vixie, 1996.
*/
static int
-inet_pton4(const char *src, u_char *dst, int pton)
+inet_pton4(const char *src, unsigned char *dst, int pton)
{
- u_int val;
- u_int digit;
- int base, n;
+ uint32_t val;
+ unsigned int digit, base;
+ int n;
unsigned char c;
- u_int parts[4];
- register u_int *pp = parts;
+ unsigned int parts[4];
+ unsigned int *pp = parts;
c = *src;
for (;;) {
@@ -179,7 +188,7 @@ inet_pton4(const char *src, u_char *dst, int pton)
}
if (dst) {
val = htonl(val);
- memcpy(dst, &val, INADDRSZ);
+ memcpy(dst, &val, NS_INADDRSZ);
}
return (1);
}
@@ -199,17 +208,17 @@ inet_pton4(const char *src, u_char *dst, int pton)
* Paul Vixie, 1996.
*/
static int
-inet_pton6(const char *src, u_char *dst)
+inet_pton6(const char *src, unsigned char *dst)
{
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
- u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
+ unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
- u_int val;
+ unsigned int val;
- memset((tp = tmp), '\0', IN6ADDRSZ);
- endp = tp + IN6ADDRSZ;
+ memset((tp = tmp), '\0', NS_IN6ADDRSZ);
+ endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
@@ -242,25 +251,25 @@ inet_pton6(const char *src, u_char *dst)
return (0);
if (tp + INT16SZ > endp)
return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
+ *tp++ = (unsigned char) (val >> 8) & 0xff;
+ *tp++ = (unsigned char) val & 0xff;
saw_xdigit = 0;
val = 0;
continue;
}
- if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
+ if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, tp, 1) > 0) {
- tp += INADDRSZ;
+ tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
return (0);
}
if (saw_xdigit) {
- if (tp + INT16SZ > endp)
+ if (tp + NS_INT16SZ > endp)
return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
+ *tp++ = (unsigned char) (val >> 8) & 0xff;
+ *tp++ = (unsigned char) val & 0xff;
}
if (colonp != NULL) {
/*
@@ -280,7 +289,7 @@ inet_pton6(const char *src, u_char *dst)
}
if (tp != endp)
return (0);
- memcpy(dst, tmp, IN6ADDRSZ);
+ memcpy(dst, tmp, NS_IN6ADDRSZ);
return (1);
}
#endif
diff --git a/net/tnftp/files/libnetbsd/mkstemp.c b/net/tnftp/files/libnetbsd/mkstemp.c
index 2941a14f0f9..d1b40ea42b8 100644
--- a/net/tnftp/files/libnetbsd/mkstemp.c
+++ b/net/tnftp/files/libnetbsd/mkstemp.c
@@ -1,5 +1,5 @@
-/* NetBSD: mkstemp.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: gettemp.c,v 1.5 1999/09/20 04:39:30 lukem Exp */
+/* NetBSD: mkstemp.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
+/* from NetBSD: gettemp.c,v 1.13 2003/12/05 00:57:36 uebayasi Exp */
/*
* Copyright (c) 1987, 1993
@@ -13,11 +13,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.
*
@@ -41,7 +37,7 @@ mkstemp(char *path)
{
char *start, *trv;
struct stat sbuf;
- u_int pid;
+ unsigned int pid;
int fd;
/* To guarantee multiple calls generate unique names even if
@@ -60,9 +56,9 @@ mkstemp(char *path)
xcnt = 0;
/* Use at least one from xtra. Use 2 if more than 6 X's. */
- if (*(trv-1) == 'X')
+ if (*(trv - 1) == 'X')
*--trv = xtra[0];
- if (xcnt > 6 && *(trv-1) == 'X')
+ if (xcnt > 6 && *(trv - 1) == 'X')
*--trv = xtra[1];
/* Set remaining X's to pid digits with 0's to the left. */
@@ -103,7 +99,7 @@ mkstemp(char *path)
}
for (;;) {
- if ((fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
+ if ((fd = open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)
return (fd);
if (errno != EEXIST)
return (-1);
diff --git a/net/tnftp/files/libnetbsd/sl_init.c b/net/tnftp/files/libnetbsd/sl_init.c
index 71e86c428d4..f1b64ecffd2 100644
--- a/net/tnftp/files/libnetbsd/sl_init.c
+++ b/net/tnftp/files/libnetbsd/sl_init.c
@@ -1,5 +1,5 @@
-/* NetBSD: sl_init.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: stringlist.c,v 1.8 1999/11/28 03:44:09 lukem Exp */
+/* NetBSD: sl_init.c,v 1.4 2005/05/16 06:37:47 lukem Exp */
+/* from NetBSD: stringlist.c,v 1.10 2000/01/25 16:24:40 enami Exp */
/*-
* Copyright (c) 1994, 1999 The NetBSD Foundation, Inc.
@@ -73,10 +73,11 @@ sl_add(StringList *sl, char *name)
if (sl->sl_cur == sl->sl_max - 1) {
char **new;
- sl->sl_max += _SL_CHUNKSIZE;
- new = (char **)realloc(sl->sl_str, sl->sl_max * sizeof(char *));
+ new = (char **)realloc(sl->sl_str,
+ (sl->sl_max + _SL_CHUNKSIZE) * sizeof(char *));
if (new == NULL)
return (-1);
+ sl->sl_max += _SL_CHUNKSIZE;
sl->sl_str = new;
}
sl->sl_str[sl->sl_cur++] = name;
@@ -114,7 +115,7 @@ sl_find(StringList *sl, char *name)
for (i = 0; i < sl->sl_cur; i++)
if (strcmp(sl->sl_str[i], name) == 0)
- return sl->sl_str[i];
+ return (sl->sl_str[i]);
return (NULL);
}
diff --git a/net/tnftp/files/libnetbsd/strdup.c b/net/tnftp/files/libnetbsd/strdup.c
index e6c0c32a1a6..75a4005e263 100644
--- a/net/tnftp/files/libnetbsd/strdup.c
+++ b/net/tnftp/files/libnetbsd/strdup.c
@@ -1,5 +1,5 @@
-/* NetBSD: strdup.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: strdup.c,v 1.11 1999/09/20 04:3 9:46 lukem Exp */
+/* NetBSD: strdup.c,v 1.4 2005/05/16 06:40:04 lukem Exp */
+/* from NetBSD: strdup.c,v 1.13 2003/08/07 16:43:50 agc Exp */
/*
* Copyright (c) 1988, 1993
@@ -13,11 +13,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/net/tnftp/files/libnetbsd/strlcat.c b/net/tnftp/files/libnetbsd/strlcat.c
index e50fa35adec..523a8b2506d 100644
--- a/net/tnftp/files/libnetbsd/strlcat.c
+++ b/net/tnftp/files/libnetbsd/strlcat.c
@@ -1,32 +1,21 @@
-/* NetBSD: strlcat.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp */
-/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
+/* NetBSD: strlcat.c,v 1.4 2005/05/16 06:55:48 lukem Exp */
+/* from NetBSD: strlcat.c,v 1.16 2003/10/27 00:12:42 lukem Exp */
+/* from OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * 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.
*
- * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER 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.
*/
#include "tnftp.h"
@@ -34,8 +23,9 @@
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
*/
size_t
strlcat(char *dst, const char *src, size_t siz)
@@ -46,7 +36,7 @@ strlcat(char *dst, const char *src, size_t siz)
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
- while (*d != '\0' && n-- != 0)
+ while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;
diff --git a/net/tnftp/files/libnetbsd/strlcpy.c b/net/tnftp/files/libnetbsd/strlcpy.c
index 9446235b5e7..7f2d4d07438 100644
--- a/net/tnftp/files/libnetbsd/strlcpy.c
+++ b/net/tnftp/files/libnetbsd/strlcpy.c
@@ -1,32 +1,21 @@
-/* NetBSD: strlcpy.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp */
-/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
+/* NetBSD: strlcpy.c,v 1.4 2005/05/16 06:58:06 lukem Exp */
+/* from NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp */
+/* from OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * 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.
*
- * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER 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.
*/
#include "tnftp.h"
diff --git a/net/tnftp/files/libnetbsd/strsep.c b/net/tnftp/files/libnetbsd/strsep.c
index 565728be0ef..762915452be 100644
--- a/net/tnftp/files/libnetbsd/strsep.c
+++ b/net/tnftp/files/libnetbsd/strsep.c
@@ -1,5 +1,5 @@
-/* NetBSD: strsep.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: strsep.c,v 1.10 1999/09/20 04:39:48 lukem Exp */
+/* NetBSD: strsep.c,v 1.4 2005/05/16 08:51:51 lukem Exp */
+/* from NetBSD: strsep.c,v 1.14 2003/08/07 16:43:52 agc Exp */
/*-
* Copyright (c) 1990, 1993
@@ -13,11 +13,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/net/tnftp/files/libnetbsd/strtoll.c b/net/tnftp/files/libnetbsd/strtoll.c
index a67fddd51ef..f2801d826fa 100644
--- a/net/tnftp/files/libnetbsd/strtoll.c
+++ b/net/tnftp/files/libnetbsd/strtoll.c
@@ -1,5 +1,5 @@
-/* NetBSD: strtoll.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: strtoq.c,v 1.14 1999/09/20 04:39:42 lukem Exp */
+/* NetBSD: strtoll.c,v 1.4 2005/05/16 11:27:58 lukem Exp */
+/* from NetBSD: strtoll.c,v 1.6 2003/10/27 00:12:42 lukem Exp */
/*-
* Copyright (c) 1992, 1993
@@ -13,11 +13,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.
*
@@ -37,16 +33,17 @@
#include "tnftp.h"
/*
- * Convert a string to a quad integer.
+ * Convert a string to a long long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
-long long
+long long int
strtoll(const char *nptr, char **endptr, int base)
{
const char *s;
- long long acc, cutoff;
+ /* LONGLONG */
+ long long int acc, cutoff;
int c;
int neg, any, cutlim;
@@ -90,7 +87,7 @@ strtoll(const char *nptr, char **endptr, int base)
* followed by a legal input character, is too big. One that
* is equal to this value may be valid or not; the limit
* between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for quads is
+ * digit. For instance, if the range for long longs is
* [-9223372036854775808..9223372036854775807] and the input base
* is 10, cutoff will be set to 922337203685477580 and cutlim to
* either 7 (neg==0) or 8 (neg==1), meaning that if we have
@@ -101,7 +98,7 @@ strtoll(const char *nptr, char **endptr, int base)
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
- cutoff = neg ? QUAD_MIN : QUAD_MAX;
+ cutoff = neg ? LLONG_MIN : LLONG_MAX;
cutlim = (int)(cutoff % base);
cutoff /= base;
if (neg) {
@@ -125,7 +122,7 @@ strtoll(const char *nptr, char **endptr, int base)
if (neg) {
if (acc < cutoff || (acc == cutoff && c > cutlim)) {
any = -1;
- acc = QUAD_MIN;
+ acc = LLONG_MIN;
errno = ERANGE;
} else {
any = 1;
@@ -135,7 +132,7 @@ strtoll(const char *nptr, char **endptr, int base)
} else {
if (acc > cutoff || (acc == cutoff && c > cutlim)) {
any = -1;
- acc = QUAD_MAX;
+ acc = LLONG_MAX;
errno = ERANGE;
} else {
any = 1;
diff --git a/net/tnftp/files/libnetbsd/strunvis.c b/net/tnftp/files/libnetbsd/strunvis.c
index 35d1c78f895..562a5395dfd 100644
--- a/net/tnftp/files/libnetbsd/strunvis.c
+++ b/net/tnftp/files/libnetbsd/strunvis.c
@@ -1,5 +1,5 @@
-/* NetBSD: strunvis.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: unvis.c,v 1.16 1999/09/20 04:39:06 lukem Exp */
+/* NetBSD: strunvis.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
+/* from NetBSD: unvis.c,v 1.27 2005/05/16 11:42:04 lukem Exp */
/*-
* Copyright (c) 1989, 1993
@@ -13,11 +13,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.
*
@@ -46,8 +42,11 @@
#define S_CTRL 4 /* control char started (^) */
#define S_OCTAL2 5 /* octal digit 2 */
#define S_OCTAL3 6 /* octal digit 3 */
+#define S_HEX1 7 /* hex digit */
+#define S_HEX2 8 /* hex digit 2 */
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
+#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
+#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
/*
* unvis - decode characters previously encoded by vis
@@ -55,12 +54,14 @@
int
unvis(char *cp, int c, int *astate, int flag)
{
+ unsigned char uc = (unsigned char)c;
if (flag & UNVIS_END) {
- if (*astate == S_OCTAL2 || *astate == S_OCTAL3) {
+ if (*astate == S_OCTAL2 || *astate == S_OCTAL3
+ || *astate == S_HEX2) {
*astate = S_GROUND;
return (UNVIS_VALID);
- }
+ }
return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
}
@@ -71,7 +72,11 @@ unvis(char *cp, int c, int *astate, int flag)
if (c == '\\') {
*astate = S_START;
return (0);
- }
+ }
+ if ((flag & VIS_HTTPSTYLE) && c == '%') {
+ *astate = S_HEX1;
+ return (0);
+ }
*cp = c;
return (UNVIS_VALID);
@@ -144,7 +149,7 @@ unvis(char *cp, int c, int *astate, int flag)
}
*astate = S_GROUND;
return (UNVIS_SYNBAD);
-
+
case S_META:
if (c == '-')
*astate = S_META1;
@@ -155,12 +160,12 @@ unvis(char *cp, int c, int *astate, int flag)
return (UNVIS_SYNBAD);
}
return (0);
-
+
case S_META1:
*astate = S_GROUND;
*cp |= c;
return (UNVIS_VALID);
-
+
case S_CTRL:
if (c == '?')
*cp |= 0177;
@@ -170,23 +175,23 @@ unvis(char *cp, int c, int *astate, int flag)
return (UNVIS_VALID);
case S_OCTAL2: /* second possible octal digit */
- if (isoctal(c)) {
- /*
- * yes - and maybe a third
+ if (isoctal(uc)) {
+ /*
+ * yes - and maybe a third
*/
*cp = (*cp << 3) + (c - '0');
- *astate = S_OCTAL3;
+ *astate = S_OCTAL3;
return (0);
- }
- /*
- * no - done with current sequence, push back passed char
+ }
+ /*
+ * no - done with current sequence, push back passed char
*/
*astate = S_GROUND;
return (UNVIS_VALIDPUSH);
case S_OCTAL3: /* third possible octal digit */
*astate = S_GROUND;
- if (isoctal(c)) {
+ if (isoctal(uc)) {
*cp = (*cp << 3) + (c - '0');
return (UNVIS_VALID);
}
@@ -194,10 +199,30 @@ unvis(char *cp, int c, int *astate, int flag)
* we were done, push back passed char
*/
return (UNVIS_VALIDPUSH);
-
- default:
- /*
- * decoder in unknown state - (probably uninitialized)
+
+ case S_HEX1:
+ if (isxdigit(uc)) {
+ *cp = xtod(uc);
+ *astate = S_HEX2;
+ return (0);
+ }
+ /*
+ * no - done with current sequence, push back passed char
+ */
+ *astate = S_GROUND;
+ return (UNVIS_VALIDPUSH);
+
+ case S_HEX2:
+ *astate = S_GROUND;
+ if (isxdigit(uc)) {
+ *cp = xtod(uc) | (*cp << 4);
+ return (UNVIS_VALID);
+ }
+ return (UNVIS_VALIDPUSH);
+
+ default:
+ /*
+ * decoder in unknown state - (probably uninitialized)
*/
*astate = S_GROUND;
return (UNVIS_SYNBAD);
@@ -205,22 +230,22 @@ unvis(char *cp, int c, int *astate, int flag)
}
/*
- * strunvis - decode src into dst
+ * strunvis - decode src into dst
*
* Number of chars decoded into dst is returned, -1 on error.
* Dst is null terminated.
*/
int
-strunvis(char *dst, const char *src)
+strunvisx(char *dst, const char *src, int flag)
{
char c;
char *start = dst;
int state = 0;
while ((c = *src++) != '\0') {
- again:
- switch (unvis(dst, c, &state, 0)) {
+ again:
+ switch (unvis(dst, c, &state, flag)) {
case UNVIS_VALID:
dst++;
break;
@@ -239,3 +264,9 @@ strunvis(char *dst, const char *src)
*dst = '\0';
return (dst - start);
}
+
+int
+strunvis(char *dst, const char *src)
+{
+ return strunvisx(dst, src, 0);
+}
diff --git a/net/tnftp/files/libnetbsd/strvis.c b/net/tnftp/files/libnetbsd/strvis.c
index 7f369f86334..f98d4d2a96d 100644
--- a/net/tnftp/files/libnetbsd/strvis.c
+++ b/net/tnftp/files/libnetbsd/strvis.c
@@ -1,5 +1,5 @@
-/* NetBSD: strvis.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
-/* from NetBSD: vis.c,v 1.13 1999/09/20 04:39:07 lukem Exp */
+/* NetBSD: strvis.c,v 1.8 2005/06/01 11:48:49 lukem Exp */
+/* from NetBSD: vis.c,v 1.33 2005/05/28 13:11:14 lukem Exp */
/*-
* Copyright (c) 1989, 1993
@@ -13,11 +13,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.
*
@@ -34,107 +30,291 @@
* SUCH DAMAGE.
*/
+/*-
+ * Copyright (c) 1999, 2005 The NetBSD Foundation, Inc.
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 "tnftp.h"
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
+#undef BELL
+#define BELL '\a'
+
+#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
+#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
+#define issafe(c) (c == '\b' || c == BELL || c == '\r')
+#define xtoa(c) "0123456789abcdef"[c]
+
+#define MAXEXTRAS 5
+
+
+#define MAKEEXTRALIST(flag, extra, orig) \
+do { \
+ const char *o = orig; \
+ char *e; \
+ while (*o++) \
+ continue; \
+ extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \
+ if (!extra) break; \
+ for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
+ continue; \
+ e--; \
+ if (flag & VIS_SP) *e++ = ' '; \
+ if (flag & VIS_TAB) *e++ = '\t'; \
+ if (flag & VIS_NL) *e++ = '\n'; \
+ if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
+ *e = '\0'; \
+} while (/*CONSTCOND*/0)
+
/*
- * vis - visually encode characters
+ * This is HVIS, the macro of vis used to HTTP style (RFC 1808)
+ */
+#define HVIS(dst, c, flag, nextc, extra) \
+do \
+ if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
+ *dst++ = '%'; \
+ *dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
+ *dst++ = xtoa((unsigned int)c & 0xf); \
+ } else { \
+ SVIS(dst, c, flag, nextc, extra); \
+ } \
+while (/*CONSTCOND*/0)
+
+/*
+ * This is SVIS, the central macro of vis.
+ * dst: Pointer to the destination buffer
+ * c: Character to encode
+ * flag: Flag word
+ * nextc: The character following 'c'
+ * extra: Pointer to the list of extra characters to be
+ * backslash-protected.
+ */
+#define SVIS(dst, c, flag, nextc, extra) \
+do { \
+ int isextra; \
+ isextra = strchr(extra, c) != NULL; \
+ if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
+ ((flag & VIS_SAFE) && issafe(c)))) { \
+ *dst++ = c; \
+ break; \
+ } \
+ if (flag & VIS_CSTYLE) { \
+ switch (c) { \
+ case '\n': \
+ *dst++ = '\\'; *dst++ = 'n'; \
+ continue; \
+ case '\r': \
+ *dst++ = '\\'; *dst++ = 'r'; \
+ continue; \
+ case '\b': \
+ *dst++ = '\\'; *dst++ = 'b'; \
+ continue; \
+ case BELL: \
+ *dst++ = '\\'; *dst++ = 'a'; \
+ continue; \
+ case '\v': \
+ *dst++ = '\\'; *dst++ = 'v'; \
+ continue; \
+ case '\t': \
+ *dst++ = '\\'; *dst++ = 't'; \
+ continue; \
+ case '\f': \
+ *dst++ = '\\'; *dst++ = 'f'; \
+ continue; \
+ case ' ': \
+ *dst++ = '\\'; *dst++ = 's'; \
+ continue; \
+ case '\0': \
+ *dst++ = '\\'; *dst++ = '0'; \
+ if (isoctal(nextc)) { \
+ *dst++ = '0'; \
+ *dst++ = '0'; \
+ } \
+ continue; \
+ default: \
+ if (isgraph(c)) { \
+ *dst++ = '\\'; *dst++ = c; \
+ continue; \
+ } \
+ } \
+ } \
+ if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
+ *dst++ = '\\'; \
+ *dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 6) & 03) + '0'; \
+ *dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 3) & 07) + '0'; \
+ *dst++ = (c & 07) + '0'; \
+ } else { \
+ if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
+ if (c & 0200) { \
+ c &= 0177; *dst++ = 'M'; \
+ } \
+ if (iscntrl(c)) { \
+ *dst++ = '^'; \
+ if (c == 0177) \
+ *dst++ = '?'; \
+ else \
+ *dst++ = c + '@'; \
+ } else { \
+ *dst++ = '-'; *dst++ = c; \
+ } \
+ } \
+} while (/*CONSTCOND*/0)
+
+
+/*
+ * svis - visually encode characters, also encoding the characters
+ * pointed to by `extra'
*/
char *
-vis(char *dst, int c, int flag, int nextc)
+svis(char *dst, int c, int flag, int nextc, const char *extra)
{
+ char *nextra = NULL;
- if (((u_int)c <= UCHAR_MAX && isascii(c) && isgraph(c)) ||
- ((flag & VIS_SP) == 0 && c == ' ') ||
- ((flag & VIS_TAB) == 0 && c == '\t') ||
- ((flag & VIS_NL) == 0 && c == '\n') ||
- ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) {
- *dst++ = c;
- if (c == '\\' && (flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- *dst = '\0';
- return (dst);
+ MAKEEXTRALIST(flag, nextra, extra);
+ if (!nextra) {
+ *dst = '\0'; /* can't create nextra, return "" */
+ return dst;
}
+ if (flag & VIS_HTTPSTYLE)
+ HVIS(dst, c, flag, nextc, nextra);
+ else
+ SVIS(dst, c, flag, nextc, nextra);
+ free(nextra);
+ *dst = '\0';
+ return dst;
+}
- if (flag & VIS_CSTYLE) {
- switch(c) {
- case '\n':
- *dst++ = '\\';
- *dst++ = 'n';
- goto done;
- case '\r':
- *dst++ = '\\';
- *dst++ = 'r';
- goto done;
- case '\b':
- *dst++ = '\\';
- *dst++ = 'b';
- goto done;
- case '\a':
- *dst++ = '\\';
- *dst++ = 'a';
- goto done;
- case '\v':
- *dst++ = '\\';
- *dst++ = 'v';
- goto done;
- case '\t':
- *dst++ = '\\';
- *dst++ = 't';
- goto done;
- case '\f':
- *dst++ = '\\';
- *dst++ = 'f';
- goto done;
- case ' ':
- *dst++ = '\\';
- *dst++ = 's';
- goto done;
- case '\0':
- *dst++ = '\\';
- *dst++ = '0';
- if (isoctal(nextc)) {
- *dst++ = '0';
- *dst++ = '0';
- }
- goto done;
- }
+
+/*
+ * strsvis, strsvisx - visually encode characters from src into dst
+ *
+ * Extra is a pointer to a \0-terminated list of characters to
+ * be encoded, too. These functions are useful e. g. to
+ * encode strings in such a way so that they are not interpreted
+ * by a shell.
+ *
+ * Dst must be 4 times the size of src to account for possible
+ * expansion. The length of dst, not including the trailing NULL,
+ * is returned.
+ *
+ * Strsvisx encodes exactly len bytes from src into dst.
+ * This is useful for encoding a block of data.
+ */
+int
+strsvis(char *dst, const char *csrc, int flag, const char *extra)
+{
+ int c;
+ char *start;
+ char *nextra = NULL;
+ const unsigned char *src = (const unsigned char *)csrc;
+
+ MAKEEXTRALIST(flag, nextra, extra);
+ if (!nextra) {
+ *dst = '\0'; /* can't create nextra, return "" */
+ return 0;
}
- if (((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
- *dst++ = '\\';
- *dst++ = ((((unsigned int)c) >> 6) & 07) + '0';
- *dst++ = ((((unsigned int)c) >> 3) & 07) + '0';
- *dst++ = (((u_char)c) & 07) + '0';
- goto done;
+ if (flag & VIS_HTTPSTYLE) {
+ for (start = dst; (c = *src++) != '\0'; /* empty */)
+ HVIS(dst, c, flag, *src, nextra);
+ } else {
+ for (start = dst; (c = *src++) != '\0'; /* empty */)
+ SVIS(dst, c, flag, *src, nextra);
}
- if ((flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- if (c & 0200) {
- c &= 0177;
- *dst++ = 'M';
+ free(nextra);
+ *dst = '\0';
+ return (dst - start);
+}
+
+
+int
+strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
+{
+ unsigned char c;
+ char *start;
+ char *nextra = NULL;
+ const unsigned char *src = (const unsigned char *)csrc;
+
+ MAKEEXTRALIST(flag, nextra, extra);
+ if (! nextra) {
+ *dst = '\0'; /* can't create nextra, return "" */
+ return 0;
}
- if (iscntrl(c)) {
- *dst++ = '^';
- if (c == 0177)
- *dst++ = '?';
- else
- *dst++ = c + '@';
+
+ if (flag & VIS_HTTPSTYLE) {
+ for (start = dst; len > 0; len--) {
+ c = *src++;
+ HVIS(dst, c, flag, len ? *src : '\0', nextra);
+ }
} else {
- *dst++ = '-';
- *dst++ = c;
+ for (start = dst; len > 0; len--) {
+ c = *src++;
+ SVIS(dst, c, flag, len ? *src : '\0', nextra);
+ }
}
-done:
+ free(nextra);
*dst = '\0';
- return (dst);
+ return (dst - start);
}
/*
+ * vis - visually encode characters
+ */
+char *
+vis(char *dst, int c, int flag, int nextc)
+{
+ char *extra = NULL;
+ unsigned char uc = (unsigned char)c;
+
+ MAKEEXTRALIST(flag, extra, "");
+ if (! extra) {
+ *dst = '\0'; /* can't create extra, return "" */
+ return dst;
+ }
+ if (flag & VIS_HTTPSTYLE)
+ HVIS(dst, uc, flag, nextc, extra);
+ else
+ SVIS(dst, uc, flag, nextc, extra);
+ free(extra);
+ *dst = '\0';
+ return dst;
+}
+
+
+/*
* strvis, strvisx - visually encode characters from src into dst
- *
+ *
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
- * is returned.
+ * is returned.
*
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
@@ -142,28 +322,32 @@ done:
int
strvis(char *dst, const char *src, int flag)
{
- char c;
- char *start;
+ char *extra = NULL;
+ int rv;
- for (start = dst; (c = *src) != '\0';)
- dst = vis(dst, c, flag, *++src);
- *dst = '\0';
- return (dst - start);
+ MAKEEXTRALIST(flag, extra, "");
+ if (!extra) {
+ *dst = '\0'; /* can't create extra, return "" */
+ return 0;
+ }
+ rv = strsvis(dst, src, flag, extra);
+ free(extra);
+ return rv;
}
+
int
strvisx(char *dst, const char *src, size_t len, int flag)
{
- char c;
- char *start;
+ char *extra = NULL;
+ int rv;
- for (start = dst; len > 1; len--) {
- c = *src;
- dst = vis(dst, c, flag, *++src);
+ MAKEEXTRALIST(flag, extra, "");
+ if (!extra) {
+ *dst = '\0'; /* can't create extra, return "" */
+ return 0;
}
- if (len)
- dst = vis(dst, *src, flag, '\0');
- *dst = '\0';
-
- return (dst - start);
+ rv = strsvisx(dst, src, len, flag, extra);
+ free(extra);
+ return rv;
}
diff --git a/net/tnftp/files/libnetbsd/usleep.c b/net/tnftp/files/libnetbsd/usleep.c
index 788d51694bb..f729e2d0506 100644
--- a/net/tnftp/files/libnetbsd/usleep.c
+++ b/net/tnftp/files/libnetbsd/usleep.c
@@ -1,7 +1,7 @@
-/* NetBSD: usleep.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* NetBSD: usleep.c,v 1.4 2005/05/16 13:21:43 lukem Exp */
/*-
- * Copyright (c) 1999-2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999,2000,2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -41,14 +41,14 @@
int
usleep(unsigned int usec)
{
-#if HAVE_SELECT
+#if HAVE_POLL
+ return (poll(NULL, 0, usec / 1000);
+#elif HAVE_SELECT
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = usec;
return (select(1, NULL, NULL, NULL, &tv));
-#elif HAVE_POLL
- return (poll(NULL, 0, usec / 1000);
#else
# error no way to implement usleep
#endif