[Pkg-privacy-commits] [onioncat] 55/340: included GPL and strl-functions

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository onioncat.

commit 27394e58b6980c6253048d42b77938d84e398373
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Fri Jun 6 08:33:58 2008 +0000

    included GPL and strl-functions
    
    git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@221 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 config.h.in      |  3 +++
 configure        | 29 +++++++++++------------
 configure.ac     |  4 ++--
 src/Makefile.am  |  2 +-
 src/ocat.c       | 17 ++++++++++++++
 src/ocat.h       | 28 +++++++++++++++++------
 src/ocatcompat.c | 56 ++++++++++++++++-----------------------------
 src/ocatlog.c    | 17 ++++++++++++++
 src/ocatpeer.c   | 23 ++++++++++++++++---
 src/ocatroute.c  | 17 ++++++++++++++
 src/ocatthread.c | 24 +++++++++++++++----
 src/ocattun.c    | 21 +++++++++++++++--
 src/ocatv6conv.c | 44 +++++++++++++++--------------------
 src/strlcat.c    | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/strlcpy.c    | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
 15 files changed, 321 insertions(+), 95 deletions(-)

diff --git a/config.h.in b/config.h.in
index 8993045..9921b07 100644
--- a/config.h.in
+++ b/config.h.in
@@ -30,6 +30,9 @@
 /* Define to 1 if you have the `strlcat' function. */
 #undef HAVE_STRLCAT
 
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
 /* Define to 1 if the system has the type `struct ip6_hdr'. */
 #undef HAVE_STRUCT_IP6_HDR
 
diff --git a/configure b/configure
index a807748..baa650d 100755
--- a/configure
+++ b/configure
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for onioncat 0.1.6.
+# Generated by GNU Autoconf 2.61 for onioncat 0.1.7.
 #
-# Report bugs to <eagle at cypherpunk.at>.
+# Report bugs to <rahra at cypherpunk.at>.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -574,9 +574,9 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='onioncat'
 PACKAGE_TARNAME='onioncat'
-PACKAGE_VERSION='0.1.6'
-PACKAGE_STRING='onioncat 0.1.6'
-PACKAGE_BUGREPORT='eagle at cypherpunk.at'
+PACKAGE_VERSION='0.1.7'
+PACKAGE_STRING='onioncat 0.1.7'
+PACKAGE_BUGREPORT='rahra at cypherpunk.at'
 
 ac_subst_vars='SHELL
 PATH_SEPARATOR
@@ -1166,7 +1166,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures onioncat 0.1.6 to adapt to many kinds of systems.
+\`configure' configures onioncat 0.1.7 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1232,7 +1232,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of onioncat 0.1.6:";;
+     short | recursive ) echo "Configuration of onioncat 0.1.7:";;
    esac
   cat <<\_ACEOF
 
@@ -1254,7 +1254,7 @@ Some influential environment variables:
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
-Report bugs to <eagle at cypherpunk.at>.
+Report bugs to <rahra at cypherpunk.at>.
 _ACEOF
 ac_status=$?
 fi
@@ -1315,7 +1315,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-onioncat configure 0.1.6
+onioncat configure 0.1.7
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1329,7 +1329,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by onioncat $as_me 0.1.6, which was
+It was created by onioncat $as_me 0.1.7, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2019,7 +2019,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='onioncat'
- VERSION='0.1.6'
+ VERSION='0.1.7'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3737,7 +3737,8 @@ fi
 #AC_FUNC_VPRINTF
 #AC_CHECK_FUNCS([clock_gettime memset select socket strchr strerror])
 
-for ac_func in strlcat
+
+for ac_func in strlcat strlcpy
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -4243,7 +4244,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by onioncat $as_me 0.1.6, which was
+This file was extended by onioncat $as_me 0.1.7, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4296,7 +4297,7 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-onioncat config.status 0.1.6
+onioncat config.status 0.1.7
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
diff --git a/configure.ac b/configure.ac
index 2d17241..5160cc8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.61)
-AC_INIT([onioncat], [0.1.6], [eagle at cypherpunk.at])
+AC_INIT([onioncat], [0.1.7], [rahra at cypherpunk.at])
 AM_INIT_AUTOMAKE([-Wall -Werror])
 #AC_CONFIG_SRCDIR([ocatroute.c])
 AC_CONFIG_HEADERS([config.h])
@@ -79,7 +79,7 @@ AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
 #AC_FUNC_STRFTIME
 #AC_FUNC_VPRINTF
 #AC_CHECK_FUNCS([clock_gettime memset select socket strchr strerror])
-AC_CHECK_FUNCS([strlcat])
+AC_CHECK_FUNCS([strlcat strlcpy])
 
 AC_CONFIG_FILES([Makefile src/Makefile])
 AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 51be3be..ddabf01 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
 bin_PROGRAMS = ocat
 ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c
-include_HEADERS = ocat.h
+include_HEADERS = ocat.h strlcpy.c strlcat.c
 
diff --git a/src/ocat.c b/src/ocat.c
index 00c90be..0152655 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -1,3 +1,20 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "config.h"
 
 #include <stdio.h>
diff --git a/src/ocat.h b/src/ocat.h
index 17da4be..a728a3b 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -1,3 +1,20 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #ifndef OCAT_H
 #define OCAT_H
 
@@ -28,8 +45,6 @@
 #define TOR_SOCKS_PORT 9050
 #define OCAT_UNAME "tor"
 #define OCAT_UID 112
-//#define OCAT_GNAME "tor"
-//#define OCAT_GID 116
 
 //! Maximum frame (packet) size, should be able to keep one maximum size ipv6-packet: 2^16 + 40 + 4
 #define FRAME_SIZE 65580
@@ -192,10 +207,6 @@ extern OcatThread_t *octh_;
 /* ocatlog.c */
 void log_msg(int, const char *, ...);
 
-/* ocatsv6.c -- this function is sourced out
- * here because of conflicting headers. */
-void set_ipv6_addr(int, struct in6_addr, int);
-
 /* ocatv6conv.c */
 char *ipv6tonion(const struct in6_addr *, char *);
 int oniontipv6(const char *, struct in6_addr *);
@@ -224,7 +235,10 @@ const OcatThread_t *get_thread(void);
 
 /* ocatcompat.c */
 #ifndef HAVE_STRLCAT
-size_t strlcat(char *, const char *, size_t);
+size_t strlcat(char*, const char*, size_t);
+#endif
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char*, const char*, size_t);
 #endif
 
 /* ocatpeer.c */
diff --git a/src/ocatcompat.c b/src/ocatcompat.c
index a5ff097..ebdbfde 100644
--- a/src/ocatcompat.c
+++ b/src/ocatcompat.c
@@ -1,42 +1,26 @@
-#include "config.h"
-
-#include <stdio.h>
-#include <sys/types.h>
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
 
+#include "config.h"
 
 #ifndef HAVE_STRLCAT
-
-size_t strlcat(char *dst, const char *src, size_t size)
-{
-  int i;
-   for (i = 0; *dst && i < size; i++, dst++);
-   if (i >= size)
-      return size;
-   for ( ; *src && i < size; i++, dst++, src++)
-      *dst = *src;
-   if (i >= size)
-      dst--, i--;
-   *dst = '\0';
-   return i;
-}
-
+#include "strlcat.c"
 #endif
-
-
-#if 0
-
-int main(int argc, char *argv[])
-{
-   int i;
-   char buf[20] = "abcdefg";
-
-   if (argc == 1)
-      return 1;
-   i = strlcat(buf, argv[1], 20);
-   printf("%d \"%s\"\n", i, buf);
-
-   return 0;
-}
-
+#ifndef HAVE_STRLCPY
+#include "strlcpy.c"
 #endif
 
diff --git a/src/ocatlog.c b/src/ocatlog.c
index 8d289fc..e901cd0 100644
--- a/src/ocatlog.c
+++ b/src/ocatlog.c
@@ -1,3 +1,20 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "config.h"
 
 #include <stdio.h>
diff --git a/src/ocatpeer.c b/src/ocatpeer.c
index c1a5f5b..2c489f1 100644
--- a/src/ocatpeer.c
+++ b/src/ocatpeer.c
@@ -1,8 +1,25 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 /*! ocatpeer.c
- *  Contains functions for managing both kind of TCP peers.
- *  Those are active SOCKS4A and passive TCP-LISTEN.
+ *  This file contains function on managing the peer list, i.e.
+ *  adding, removing peers and thread locking mechanism.
  *
- *  @author Bernhard Fischer <rahra _at_ cypherpunk at>
+ *  @author Bernhard R. Fischer <rahra _at_ cypherpunk at>
  *  @version 2008/02/03-01
  */
 
diff --git a/src/ocatroute.c b/src/ocatroute.c
index ed816d9..a5f95f5 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -1,3 +1,20 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 /*! ocatroute.c
  *  Contains functions for managing both kind of TCP peers.
  *  Those are active SOCKS4A and passive TCP-LISTEN.
diff --git a/src/ocatthread.c b/src/ocatthread.c
index 370e733..8533f30 100644
--- a/src/ocatthread.c
+++ b/src/ocatthread.c
@@ -1,8 +1,24 @@
-/*! ocatroute.c
- *  Contains functions for managing both kind of TCP peers.
- *  Those are active SOCKS4A and passive TCP-LISTEN.
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
  *
- *  @author Bernhard Fischer <rahra _at_ cypherpunk at>
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*! ocatthread.c
+ *  contains thread management functions.
+ *
+ *  @author Bernhard R. Fischer <rahra _at_ cypherpunk at>
  *  @version 2008/02/03-01
  */
 
diff --git a/src/ocattun.c b/src/ocattun.c
index cbc1ef1..ea9d333 100644
--- a/src/ocattun.c
+++ b/src/ocattun.c
@@ -1,7 +1,24 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 /*! ocattun.c
  *  These functions create the TUN device.
  *
- *  @author Bernhard Fischer <rahra _at_ cypherpunk at>
+ *  @author Bernhard R. Fischer <rahra _at_ cypherpunk at>
  *  @version 2008/02/03-01
  */
 
@@ -58,7 +75,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
 
    if(ioctl(fd, TUNSETIFF, (void *) &ifr) < 0)
       perror("TUNSETIFF"), exit(1);
-   strcpy(dev, ifr.ifr_name);
+   strlcpy(dev, ifr.ifr_name, IFNAMSIZ);
    sprintf(buf, "ifconfig tun0 add %s/%d up", astr, TOR_PREFIX_LEN);
    log_msg(L_NOTICE, "configuring tun IP: \"%s\"", buf);
    if (system(buf) == -1)
diff --git a/src/ocatv6conv.c b/src/ocatv6conv.c
index 8d552fb..abe9f89 100644
--- a/src/ocatv6conv.c
+++ b/src/ocatv6conv.c
@@ -1,8 +1,25 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 /*! ocatv6conv.c
  *  These functions convert IPv6 addresses to onion URLs
  *  and vice versa.
  *
- *  @author Bernhard Fischer <rahra _at_ cypherpunkt at>
+ *  @author Bernhard R. Fischer <rahra _at_ cypherpunkt at>
  *  @version 2008/02/03-01
  */
 
@@ -10,16 +27,10 @@
 
 #include <ctype.h>
 #include <string.h>
-//#include <stdint.h>
 #include <sys/types.h>
-/*
-#include <netinet/in.h>
-#include <netinet/ip6.h>
-*/
 
 #include "ocat.h"
 
-//static const char BASE32[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','j','k','m','n','o','p','q','r','s','t','v','w','x','y','z'};
 static const char BASE32[] = "abcdefghijklmnopqrstuvwxyz234567";
 static const char tor_prefix_[] = TOR_PREFIX;
 
@@ -34,24 +45,12 @@ int is_testping(const struct in6_addr *addr)
 int has_tor_prefix(const struct in6_addr *addr)
 {
    return memcmp(addr, tor_prefix_, 6) == 0;
-/*
-   int i;
-
-   for (i = 0; i < 6; i++)
-      if (*(((char*) addr) + i) != tor_prefix_[i])
-         return 0;
-   return 1;*/
 }
 
 
 void set_tor_prefix(struct in6_addr *addr)
 {
    memcpy(addr, tor_prefix_, 6);
-/*
-   int i;
-
-   for (i = 0; i < 6; i++)
-      *(((char*) addr) + i) = tor_prefix_[i];*/
 }
 
 
@@ -100,13 +99,6 @@ char *ipv6tonion(const struct in6_addr *ip6, char *onion)
    {
       *onion = BASE32[bin[0] >> 3 & 0x1f];
       shl5(bin);
-      /*
-      for (j = 0; j < 15; j++)
-      {
-         bin[j] <<= 5;
-         bin[j] |= (bin[j + 1] >> 3) & 0x1f;
-      }
-      */
    }
    *onion = '\0';
    return r;
diff --git a/src/strlcat.c b/src/strlcat.c
new file mode 100644
index 0000000..316733b
--- /dev/null
+++ b/src/strlcat.c
@@ -0,0 +1,70 @@
+/*	$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller at 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.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * 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 <= 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)
+{
+	register char *d = dst;
+	register const char *s = src;
+	register size_t n = siz;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end */
+	while (n-- != 0 && *d != '\0')
+		d++;
+	dlen = d - dst;
+	n = siz - dlen;
+
+	if (n == 0)
+		return(dlen + strlen(s));
+	while (*s != '\0') {
+		if (n != 1) {
+			*d++ = *s;
+			n--;
+		}
+		s++;
+	}
+	*d = '\0';
+
+	return(dlen + (s - src));	/* count does not include NUL */
+}
diff --git a/src/strlcpy.c b/src/strlcpy.c
new file mode 100644
index 0000000..f70e60b
--- /dev/null
+++ b/src/strlcpy.c
@@ -0,0 +1,61 @@
+/* $Id: strlcpy.c 8591 2006-10-03 19:00:07Z nickm $ */
+/*	$OpenBSD: strlcpy.c,v 1.2 1998/11/06 04:33:16 wvdputte Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller at 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.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: strlcpy.c,v 1.2 1998/11/06 04:33:16 wvdputte Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t strlcpy(char *dst, const char *src, size_t siz)
+{
+	register char *d = dst;
+	register const char *s = src;
+	register size_t n = siz;
+
+	if (n == 0)
+		return(strlen(s));
+	while (*s != '\0') {
+		if (n != 1) {
+			*d++ = *s;
+			n--;
+		}
+		s++;
+	}
+	*d = '\0';
+
+	return(s - src);	/* count does not include NUL */
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list