[Pkg-privacy-commits] [onioncat] 53/340: implemented strlcat() for compatibility
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 9da1a19aac90ae076ceb6be7554f67e0f881f2bd
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Thu Apr 24 13:53:16 2008 +0000
implemented strlcat() for compatibility
git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@206 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
config.h.in | 3 ++
configure | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 2 ++
src/Makefile.am | 2 +-
src/ocat.h | 4 +++
src/ocatcompat.c | 42 +++++++++++++++++++++++++
src/ocatroute.c | 4 +--
7 files changed, 149 insertions(+), 3 deletions(-)
diff --git a/config.h.in b/config.h.in
index a59ea71..8993045 100644
--- a/config.h.in
+++ b/config.h.in
@@ -27,6 +27,9 @@
/* Do we have sockaddr_in.sin_len? */
#undef HAVE_SIN_LEN
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
/* Define to 1 if the system has the type `struct ip6_hdr'. */
#undef HAVE_STRUCT_IP6_HDR
diff --git a/configure b/configure
index ff3f73e..53e5171 100755
--- a/configure
+++ b/configure
@@ -3737,6 +3737,100 @@ fi
#AC_FUNC_VPRINTF
#AC_CHECK_FUNCS([clock_gettime memset select socket strchr strerror])
+for ac_func in strlcat
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
ac_config_files="$ac_config_files Makefile src/Makefile"
cat >confcache <<\_ACEOF
@@ -5060,3 +5154,4 @@ if test "$no_create" != yes; then
$ac_cs_success || { (exit 1); exit 1; }
fi
+
diff --git a/configure.ac b/configure.ac
index 30c5ae2..8498f40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,8 @@ 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_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 5d8bc5c..ab0f1d7 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
+ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c
include_HEADERS = ocat.h
diff --git a/src/ocat.h b/src/ocat.h
index af8b680..c72fd1f 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -222,6 +222,10 @@ const OcatThread_t *init_ocat_thread(const char *);
int run_ocat_thread(const char *, void *(*)(void*), void*);
const OcatThread_t *get_thread(void);
+/* ocatcompat.c */
+#ifndef HAVE_STRLCAT
+size_t strlcat(char *, const char *, size_t);
+#endif
#endif
diff --git a/src/ocatcompat.c b/src/ocatcompat.c
new file mode 100644
index 0000000..a5ff097
--- /dev/null
+++ b/src/ocatcompat.c
@@ -0,0 +1,42 @@
+#include "config.h"
+
+#include <stdio.h>
+#include <sys/types.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;
+}
+
+#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;
+}
+
+#endif
+
diff --git a/src/ocatroute.c b/src/ocatroute.c
index b93a06c..ac84795 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -698,7 +698,7 @@ int socks_connect(const struct in6_addr *addr)
char buf[FRAME_SIZE], onion[ONION_NAME_SIZE];
SocksHdr_t *shdr = (SocksHdr_t*) buf;
- log_msg(L_DEBUG, "[socks_connect] called");
+ log_msg(L_DEBUG, "called");
memset(&in, 0, sizeof(in));
in.sin_family = AF_INET;
@@ -709,7 +709,7 @@ int socks_connect(const struct in6_addr *addr)
#endif
ipv6tonion(addr, onion);
- strcat(onion, ".onion");
+ strlcat(onion, ".onion", sizeof(onion));
log_msg(L_NOTICE, "trying to connecto to \"%s\" [%s]", onion, inet_ntop(AF_INET6, addr, buf, FRAME_SIZE));
--
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