diff --git a/libratbox/ChangeLog b/libratbox/ChangeLog index 76e0b7d0..a31a4e85 100644 --- a/libratbox/ChangeLog +++ b/libratbox/ChangeLog @@ -1,3 +1,157 @@ +androsyn 2008/07/29 15:26:55 UTC (25795) + Log: + some sanity checks in the rb_open path + + Modified: + libratbox/trunk/src/commio.c (File Modified) + + +androsyn 2008/07/29 14:47:48 UTC (25793) + Log: + pass new_F along to rb_ssl_accept_setup instead of the fd itself + + Modified: + libratbox/trunk/include/commio-ssl.h (File Modified) + libratbox/trunk/src/commio.c (File Modified) + libratbox/trunk/src/gnutls.c (File Modified) + libratbox/trunk/src/nossl.c (File Modified) + libratbox/trunk/src/openssl.c (File Modified) + + +androsyn 2008/07/28 23:14:29 UTC (25791) + Log: + log if rb_open returns NULL on accept and close the fd..this shouldn't happen and the real cause needs to be found + + Modified: + libratbox/trunk/src/commio.c (File Modified) + + +androsyn 2008/07/11 18:21:57 UTC (25705) + Log: + add a newline at the end of arc4random.c + + Modified: + libratbox/trunk/src/arc4random.c (File Modified) + + +androsyn 2008/07/10 18:34:03 UTC (25699) + Log: + i'm doing good today..move the ifdefs down + + Modified: + libratbox/trunk/src/arc4random.c (File Modified) + + +androsyn 2008/07/10 18:32:34 UTC (25697) + Log: + remove some debugging code + + Modified: + libratbox/trunk/src/arc4random.c (File Modified) + libratbox/trunk/src/nossl.c (File Modified) + + +androsyn 2008/07/10 18:30:19 UTC (25695) + Log: + add a missing ; and add arc4random.h too + + Modified: + libratbox/trunk/include/arc4random.h (File Added) + libratbox/trunk/src/openssl.c (File Modified) + + +androsyn 2008/07/10 18:27:23 UTC (25693) + Log: + forgot a prototype for rb_get_pseudo_random + + Modified: + libratbox/trunk/include/rb_commio.h (File Modified) + + +androsyn 2008/07/10 18:05:43 UTC (25691) + Log: + fix a typo + + Modified: + libratbox/trunk/src/nossl.c (File Modified) + + +androsyn 2008/07/10 17:13:27 UTC (25689) + Log: + - Add arc4random as a source for random bytes in the nossl.c case. + - Add in a pseudo random source function as well. This is really only different on OpenSSL. + + + + Modified: + libratbox/trunk/configure (File Modified) + libratbox/trunk/configure.ac (File Modified) + libratbox/trunk/include/libratbox_config.h.in (File Modified) + libratbox/trunk/src/Makefile.am (File Modified) + libratbox/trunk/src/Makefile.in (File Modified) + libratbox/trunk/src/arc4random.c (File Added) + libratbox/trunk/src/export-syms.txt (File Modified) + libratbox/trunk/src/gnutls.c (File Modified) + libratbox/trunk/src/nossl.c (File Modified) + libratbox/trunk/src/openssl.c (File Modified) + + +androsyn 2008/07/06 18:57:15 UTC (25683) + Log: + change a rb_uint8_t to uint8_t + + Modified: + libratbox/trunk/configure (File Modified) + libratbox/trunk/configure.ac (File Modified) + + +androsyn 2008/07/06 05:15:22 UTC (25681) + Log: + fix the socklen_t stuff + + Modified: + libratbox/trunk/configure (File Modified) + libratbox/trunk/configure.ac (File Modified) + libratbox/trunk/include/libratbox_config.h.in (File Modified) + + +androsyn 2008/07/06 04:33:03 UTC (25679) + Log: + get rid of some testing code that snuck into the last commit + + Modified: + libratbox/trunk/configure (File Modified) + libratbox/trunk/configure.ac (File Modified) + + +androsyn 2008/07/06 04:13:05 UTC (25675) + Log: + remove the rb_uint/rb_int stuff as we require a C99 compiler and this is standard now. Also add a better check for socklen_t + + Modified: + libratbox/trunk/acinclude.m4 (File Modified) + libratbox/trunk/configure (File Modified) + libratbox/trunk/configure.ac (File Modified) + libratbox/trunk/include/commio-int.h (File Modified) + libratbox/trunk/include/libratbox_config.h.in (File Modified) + libratbox/trunk/include/rb_commio.h (File Modified) + libratbox/trunk/include/rb_linebuf.h (File Modified) + libratbox/trunk/src/Makefile.in (File Modified) + libratbox/trunk/src/balloc.c (File Modified) + libratbox/trunk/src/commio.c (File Modified) + libratbox/trunk/src/crypt.c (File Modified) + libratbox/trunk/src/epoll.c (File Modified) + libratbox/trunk/src/rawbuf.c (File Modified) + + +androsyn 2008/07/06 03:10:23 UTC (25673) + Log: + a few minor cleanups + + Modified: + libratbox/trunk/src/commio.c (File Modified) + + androsyn 2008/06/24 14:04:50 UTC (25588) Log: move some of the common accept code into a function diff --git a/libratbox/acinclude.m4 b/libratbox/acinclude.m4 index 3caeacae..7e963d5a 100644 --- a/libratbox/acinclude.m4 +++ b/libratbox/acinclude.m4 @@ -22,84 +22,6 @@ AC_DEFUN([AC_SUBST_DIR], [ ]) -# RB_TYPE_INTMAX_T -# ----------------- -AC_DEFUN([RB_TYPE_INTMAX_T], -[ - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) - AC_CHECK_TYPE([intmax_t], - [AC_DEFINE([HAVE_INTMAX_T], 1, - [Define to 1 if the system has the type `intmax_t'.]) ac_cv_c_intmax_t=yes], - [test $ac_cv_type_long_long_int = yes \ - && ac_type='long long int' \ - || ac_type='long int' - AC_DEFINE_UNQUOTED([intmax_t], [$ac_type], - [Define to the widest signed integer type - if and do not define.]) ac_cv_c_intmax_t="$ac_type"]) -]) - - -# RB_TYPE_UINTMAX_T -# ----------------- -AC_DEFUN([RB_TYPE_UINTMAX_T], -[ - AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) - AC_CHECK_TYPE([uintmax_t], - [AC_DEFINE([HAVE_UINTMAX_T], 1, - [Define to 1 if the system has the type `uintmax_t'.]) ac_cv_c_uintmax_t=yes], - [test $ac_cv_type_unsigned_long_long_int = yes \ - && ac_type='unsigned long long int' \ - || ac_type='unsigned long int' - AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type], - [Define to the widest unsigned integer type - if and do not define.]) ac_cv_c_uintmax_t="$ac_type"]) -]) - - -# RB_TYPE_INTPTR_T -# ----------------- -AC_DEFUN([RB_TYPE_INTPTR_T], -[ - AC_CHECK_TYPE([intptr_t], - [AC_DEFINE([HAVE_INTPTR_T], 1, - [Define to 1 if the system has the type `intptr_t'.]) ac_cv_c_intptr_t=yes], - [for ac_type in 'int' 'long int' 'long long int'; do - AC_COMPILE_IFELSE( - [AC_LANG_BOOL_COMPILE_TRY( - [AC_INCLUDES_DEFAULT], - [[sizeof (void *) <= sizeof ($ac_type)]])], - [AC_DEFINE_UNQUOTED([intptr_t], [$ac_type], - [Define to the type of a signed integer type wide enough to - hold a pointer, if such a type exists, and if the system - does not define it.]) ac_cv_c_intptr_t="$ac_type" - ac_type=]) - test -z "$ac_type" && break - done]) -]) - - -# RB_TYPE_UINTPTR_T -# ----------------- -AC_DEFUN([RB_TYPE_UINTPTR_T], -[ - AC_CHECK_TYPE([uintptr_t], - [AC_DEFINE([HAVE_UINTPTR_T], 1, - [Define to 1 if the system has the type `uintptr_t'.]) ac_cv_c_uintptr_t=yes], - [for ac_type in 'unsigned int' 'unsigned long int' \ - 'unsigned long long int'; do - AC_COMPILE_IFELSE( - [AC_LANG_BOOL_COMPILE_TRY( - [AC_INCLUDES_DEFAULT], - [[sizeof (void *) <= sizeof ($ac_type)]])], - [AC_DEFINE_UNQUOTED([uintptr_t], [$ac_type], - [Define to the type of an unsigned integer type wide enough to - hold a pointer, if such a type exists, and if the system - does not define it.]) ac_cv_c_uintptr_t="$ac_type" - ac_type=]) - test -z "$ac_type" && break - done]) -]) - dnl IPv6 support macros..pretty much swiped from wget dnl RB_PROTO_INET6 diff --git a/libratbox/configure b/libratbox/configure index e4634957..af408af2 100755 --- a/libratbox/configure +++ b/libratbox/configure @@ -2,7 +2,7 @@ # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for libratbox devel. # -# $Id: configure.ac 25574 2008-06-20 21:49:06Z androsyn $ +# $Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $ # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -1616,7 +1616,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. -$Id: configure.ac 25574 2008-06-20 21:49:06Z androsyn $ +$Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $ _ACEOF exit fi @@ -21382,1338 +21382,6 @@ if test "$libexecdir" = '${exec_prefix}/libexec' && localstatedir='${prefix}' fi - - { echo "$as_me:$LINENO: checking for int8_t" >&5 -echo $ECHO_N "checking for int8_t... $ECHO_C" >&6; } -if test "${ac_cv_c_int8_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_int8_t=no - for ac_type in 'int8_t' 'int' 'long int' \ - 'long long int' 'short int' 'signed char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (8 - 2)) - 1) * 2 + 1))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (8 - 2)) - 1) * 2 + 1) - < ($ac_type) (((($ac_type) 1 << (8 - 2)) - 1) * 2 + 2))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - case $ac_type in - int8_t) ac_cv_c_int8_t=yes ;; - *) ac_cv_c_int8_t=$ac_type ;; -esac - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_int8_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_int8_t" >&5 -echo "${ECHO_T}$ac_cv_c_int8_t" >&6; } - case $ac_cv_c_int8_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<_ACEOF -#define int8_t $ac_cv_c_int8_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for int16_t" >&5 -echo $ECHO_N "checking for int16_t... $ECHO_C" >&6; } -if test "${ac_cv_c_int16_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_int16_t=no - for ac_type in 'int16_t' 'int' 'long int' \ - 'long long int' 'short int' 'signed char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (16 - 2)) - 1) * 2 + 1))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (16 - 2)) - 1) * 2 + 1) - < ($ac_type) (((($ac_type) 1 << (16 - 2)) - 1) * 2 + 2))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - case $ac_type in - int16_t) ac_cv_c_int16_t=yes ;; - *) ac_cv_c_int16_t=$ac_type ;; -esac - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_int16_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_int16_t" >&5 -echo "${ECHO_T}$ac_cv_c_int16_t" >&6; } - case $ac_cv_c_int16_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<_ACEOF -#define int16_t $ac_cv_c_int16_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for int32_t" >&5 -echo $ECHO_N "checking for int32_t... $ECHO_C" >&6; } -if test "${ac_cv_c_int32_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_int32_t=no - for ac_type in 'int32_t' 'int' 'long int' \ - 'long long int' 'short int' 'signed char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 1))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 1) - < ($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 2))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - case $ac_type in - int32_t) ac_cv_c_int32_t=yes ;; - *) ac_cv_c_int32_t=$ac_type ;; -esac - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_int32_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_int32_t" >&5 -echo "${ECHO_T}$ac_cv_c_int32_t" >&6; } - case $ac_cv_c_int32_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<_ACEOF -#define int32_t $ac_cv_c_int32_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for int64_t" >&5 -echo $ECHO_N "checking for int64_t... $ECHO_C" >&6; } -if test "${ac_cv_c_int64_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_int64_t=no - for ac_type in 'int64_t' 'int' 'long int' \ - 'long long int' 'short int' 'signed char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (64 - 2)) - 1) * 2 + 1))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (64 - 2)) - 1) * 2 + 1) - < ($ac_type) (((($ac_type) 1 << (64 - 2)) - 1) * 2 + 2))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - case $ac_type in - int64_t) ac_cv_c_int64_t=yes ;; - *) ac_cv_c_int64_t=$ac_type ;; -esac - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_int64_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_int64_t" >&5 -echo "${ECHO_T}$ac_cv_c_int64_t" >&6; } - case $ac_cv_c_int64_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<_ACEOF -#define int64_t $ac_cv_c_int64_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for uint8_t" >&5 -echo $ECHO_N "checking for uint8_t... $ECHO_C" >&6; } -if test "${ac_cv_c_uint8_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_uint8_t=no - for ac_type in 'uint8_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (8 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - case $ac_type in - uint8_t) ac_cv_c_uint8_t=yes ;; - *) ac_cv_c_uint8_t=$ac_type ;; -esac - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint8_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_uint8_t" >&5 -echo "${ECHO_T}$ac_cv_c_uint8_t" >&6; } - case $ac_cv_c_uint8_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<\_ACEOF -#define _UINT8_T 1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define uint8_t $ac_cv_c_uint8_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for uint16_t" >&5 -echo $ECHO_N "checking for uint16_t... $ECHO_C" >&6; } -if test "${ac_cv_c_uint16_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_uint16_t=no - for ac_type in 'uint16_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (16 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - case $ac_type in - uint16_t) ac_cv_c_uint16_t=yes ;; - *) ac_cv_c_uint16_t=$ac_type ;; -esac - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint16_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_uint16_t" >&5 -echo "${ECHO_T}$ac_cv_c_uint16_t" >&6; } - case $ac_cv_c_uint16_t in #( - no|yes) ;; #( - *) - - -cat >>confdefs.h <<_ACEOF -#define uint16_t $ac_cv_c_uint16_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for uint32_t" >&5 -echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6; } -if test "${ac_cv_c_uint32_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_uint32_t=no - for ac_type in 'uint32_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (32 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - case $ac_type in - uint32_t) ac_cv_c_uint32_t=yes ;; - *) ac_cv_c_uint32_t=$ac_type ;; -esac - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint32_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_uint32_t" >&5 -echo "${ECHO_T}$ac_cv_c_uint32_t" >&6; } - case $ac_cv_c_uint32_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<\_ACEOF -#define _UINT32_T 1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define uint32_t $ac_cv_c_uint32_t -_ACEOF -;; - esac - - - { echo "$as_me:$LINENO: checking for uint64_t" >&5 -echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6; } -if test "${ac_cv_c_uint64_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_uint64_t=no - for ac_type in 'uint64_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (64 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - case $ac_type in - uint64_t) ac_cv_c_uint64_t=yes ;; - *) ac_cv_c_uint64_t=$ac_type ;; -esac - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint64_t" != no && break - done -fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_uint64_t" >&5 -echo "${ECHO_T}$ac_cv_c_uint64_t" >&6; } - case $ac_cv_c_uint64_t in #( - no|yes) ;; #( - *) - -cat >>confdefs.h <<\_ACEOF -#define _UINT64_T 1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define uint64_t $ac_cv_c_uint64_t -_ACEOF -;; - esac - - - - { echo "$as_me:$LINENO: checking for intptr_t" >&5 -echo $ECHO_N "checking for intptr_t... $ECHO_C" >&6; } -if test "${ac_cv_type_intptr_t+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. */ -$ac_includes_default -typedef intptr_t ac__type_new_; -int -main () -{ -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - ac_cv_type_intptr_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_intptr_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_intptr_t" >&5 -echo "${ECHO_T}$ac_cv_type_intptr_t" >&6; } -if test $ac_cv_type_intptr_t = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_INTPTR_T 1 -_ACEOF - ac_cv_c_intptr_t=yes -else - for ac_type in 'int' 'long int' 'long long int'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - -cat >>confdefs.h <<_ACEOF -#define intptr_t $ac_type -_ACEOF - ac_cv_c_intptr_t="$ac_type" - ac_type= -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test -z "$ac_type" && break - done -fi - - - - { echo "$as_me:$LINENO: checking for long long int" >&5 -echo $ECHO_N "checking for long long int... $ECHO_C" >&6; } -if test "${ac_cv_type_long_long_int+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. */ -long long int ll = 9223372036854775807ll; - long long int nll = -9223372036854775807LL; - typedef int a[((-9223372036854775807LL < 0 - && 0 < 9223372036854775807ll) - ? 1 : -1)]; - int i = 63; -int -main () -{ -long long int llmax = 9223372036854775807ll; - return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll)); - ; - 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 - if test "$cross_compiling" = yes; then - ac_cv_type_long_long_int=yes -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - #ifndef LLONG_MAX - # define HALF \ - (1LL << (sizeof (long long int) * CHAR_BIT - 2)) - # define LLONG_MAX (HALF - 1 + HALF) - #endif -int -main () -{ -long long int n = 1; - int i; - for (i = 0; ; i++) - { - long long int m = n << i; - if (m >> i != n) - return 1; - if (LLONG_MAX / 2 < m) - break; - } - return 0; - ; - return 0; -} -_ACEOF -rm -f 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>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (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_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_long_long_int=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_type_long_long_int=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_long_long_int=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_long_long_int" >&5 -echo "${ECHO_T}$ac_cv_type_long_long_int" >&6; } - if test $ac_cv_type_long_long_int = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_LONG_LONG_INT 1 -_ACEOF - - fi - - - - { echo "$as_me:$LINENO: checking for intmax_t" >&5 -echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6; } -if test "${ac_cv_type_intmax_t+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. */ -$ac_includes_default -typedef intmax_t ac__type_new_; -int -main () -{ -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - ac_cv_type_intmax_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_intmax_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_intmax_t" >&5 -echo "${ECHO_T}$ac_cv_type_intmax_t" >&6; } -if test $ac_cv_type_intmax_t = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_INTMAX_T 1 -_ACEOF - ac_cv_c_intmax_t=yes -else - test $ac_cv_type_long_long_int = yes \ - && ac_type='long long int' \ - || ac_type='long int' - -cat >>confdefs.h <<_ACEOF -#define intmax_t $ac_type -_ACEOF - ac_cv_c_intmax_t="$ac_type" -fi - - - - { echo "$as_me:$LINENO: checking for unsigned long long int" >&5 -echo $ECHO_N "checking for unsigned long long int... $ECHO_C" >&6; } -if test "${ac_cv_type_unsigned_long_long_int+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. */ -unsigned long long int ull = 18446744073709551615ULL; - typedef int a[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; - int i = 63; -int -main () -{ -unsigned long long int ullmax = 18446744073709551615ull; - return (ull << 63 | ull >> 63 | ull << i | ull >> i - | ullmax / ull | ullmax % ull); - ; - 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 - ac_cv_type_unsigned_long_long_int=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_unsigned_long_long_int=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_long_long_int" >&5 -echo "${ECHO_T}$ac_cv_type_unsigned_long_long_int" >&6; } - if test $ac_cv_type_unsigned_long_long_int = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_UNSIGNED_LONG_LONG_INT 1 -_ACEOF - - fi - - - - { echo "$as_me:$LINENO: checking for uintmax_t" >&5 -echo $ECHO_N "checking for uintmax_t... $ECHO_C" >&6; } -if test "${ac_cv_type_uintmax_t+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. */ -$ac_includes_default -typedef uintmax_t ac__type_new_; -int -main () -{ -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - ac_cv_type_uintmax_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_uintmax_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_uintmax_t" >&5 -echo "${ECHO_T}$ac_cv_type_uintmax_t" >&6; } -if test $ac_cv_type_uintmax_t = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_UINTMAX_T 1 -_ACEOF - ac_cv_c_uintmax_t=yes -else - test $ac_cv_type_unsigned_long_long_int = yes \ - && ac_type='unsigned long long int' \ - || ac_type='unsigned long int' - -cat >>confdefs.h <<_ACEOF -#define uintmax_t $ac_type -_ACEOF - ac_cv_c_uintmax_t="$ac_type" -fi - - - - { echo "$as_me:$LINENO: checking for uintptr_t" >&5 -echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6; } -if test "${ac_cv_type_uintptr_t+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. */ -$ac_includes_default -typedef uintptr_t ac__type_new_; -int -main () -{ -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - ac_cv_type_uintptr_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_uintptr_t=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 -echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6; } -if test $ac_cv_type_uintptr_t = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_UINTPTR_T 1 -_ACEOF - ac_cv_c_uintptr_t=yes -else - for ac_type in 'unsigned int' 'unsigned long int' \ - 'unsigned long long int'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -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_compile") 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_objext; then - -cat >>confdefs.h <<_ACEOF -#define uintptr_t $ac_type -_ACEOF - ac_cv_c_uintptr_t="$ac_type" - ac_type= -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test -z "$ac_type" && break - done -fi - - - { echo "$as_me:$LINENO: checking for pid_t" >&5 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } if test "${ac_cv_type_pid_t+set}" = set; then @@ -23559,18 +22227,8 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -#ifdef HAVE_SYS_TYPES_H #include -#endif -#ifdef HAVE_SYS_SOCKET_H #include -#endif -#ifdef HAVE_WINSOCK2_H -#include -#endif - - typedef socklen_t ac__type_new_; int @@ -23614,15 +22272,91 @@ fi { echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 echo "${ECHO_T}$ac_cv_type_socklen_t" >&6; } if test $ac_cv_type_socklen_t = yes; then - : + rb_socklen_t=socklen_t else -cat >>confdefs.h <<\_ACEOF -#define socklen_t unsigned int + { echo "$as_me:$LINENO: checking for socklen_t equivalent" >&5 +echo $ECHO_N "checking for socklen_t equivalent... $ECHO_C" >&6; } + if test "${rb_socklen_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + # Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + rb_socklen_t= + for arg2 in "struct sockaddr" void; do + for t in int size_t unsigned long "unsigned long"; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include + +int getpeername (int, $arg2 *, $t *); + +int +main () +{ + +$t len; +getpeername(0,0,&len); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +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_compile") 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_objext; then + + rb_socklen_t="$t" + break + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done + done + + if test "x$rb_socklen_t" = x; then + { { echo "$as_me:$LINENO: error: Cannot find a type to use in place of socklen_t" >&5 +echo "$as_me: error: Cannot find a type to use in place of socklen_t" >&2;} + { (exit 1); exit 1; }; } + fi + +fi + + { echo "$as_me:$LINENO: result: $rb_socklen_t" >&5 +echo "${ECHO_T}$rb_socklen_t" >&6; } +fi + + + + + # Check whether --enable-ipv6 was given. if test "${enable_ipv6+set}" = set; then @@ -24200,7 +22934,9 @@ fi -for ac_func in socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl + + +for ac_func in socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -26472,17 +25208,6 @@ fi -for dtype in uint64_t uint32_t uint16_t uint8_t int64_t int32_t int16_t int8_t intmax_t intptr_t uintmax_t uintptr_t -do - var="\$ac_cv_c_${dtype}" - t_type=$(eval echo $var); - if test "x$t_type" = "xyes"; then - eval rb_$dtype="\"$dtype\"" - else - eval rb_$dtype="\"$t_type\"" - fi -done - ac_config_commands="$ac_config_commands include/librb-config.h" @@ -27087,18 +25812,6 @@ cat >>$CONFIG_STATUS <<_ACEOF # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" - rb_uint64_t="$rb_uint64_t" - rb_uint32_t="$rb_uint32_t" - rb_uint16_t="$rb_uint16_t" - rb_uint8_t="$rb_uint8_t" - rb_int64_t="$rb_int64_t" - rb_int32_t="$rb_int32_t" - rb_int16_t="$rb_int16_t" - rb_int8_t="$rb_int8_t" - rb_intmax_t="$rb_intmax_t" - rb_intptr_t="$rb_intptr_t" - rb_uintmax_t="$rb_uintmax_t" - rb_uintptr_t="$rb_uintptr_t" if test x$ac_cv_header_stdc = xyes; then rb_header_stdc=yes fi @@ -27160,11 +25873,9 @@ AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" if test x$ac_cv_header_winsock2_h = xyes; then rb_winsock2_h=yes fi - if test x$ac_cv_type_socklen_t = xyes; then - rb_socklen_t="socklen_t" - else - rb_socklen_t="unsigned int" - fi + + rb_socklen_t=$rb_socklen_t + if test "x$rb_have_sockaddr_storage" = "xyes"; then rb_sockaddr_storage="yes" else @@ -28081,28 +26792,17 @@ if test "x$rb_errno_h" = "xyes"; then echo '#include ' >> $outfile fi +echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile + + if test "x$rb_sockaddr_sa_len" = "xyes"; then echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile fi -echo "typedef $rb_uint64_t rb_uint64_t;" >> $outfile -echo "typedef $rb_uint32_t rb_uint32_t;" >> $outfile -echo "typedef $rb_uint16_t rb_uint16_t;" >> $outfile -echo "typedef $rb_uint8_t rb_uint8_t;" >> $outfile -echo "typedef $rb_int64_t rb_int64_t;" >> $outfile -echo "typedef $rb_int32_t rb_int32_t;" >> $outfile -echo "typedef $rb_int16_t rb_int16_t;" >> $outfile -echo "typedef $rb_int8_t rb_int8_t;" >> $outfile -echo "typedef $rb_intmax_t rb_intmax_t;" >> $outfile -echo "typedef $rb_intptr_t rb_intptr_t;" >> $outfile -echo "typedef $rb_uintmax_t rb_uintmax_t;" >> $outfile -echo "typedef $rb_uintptr_t rb_uintptr_t;" >> $outfile -echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile - if test "x$rb_sockaddr_storage" = "xyes"; then echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile else - echo 'struct rb_sockaddr_storage { rb_uint8_t _padding128; };' >> $outfile + echo 'struct rb_sockaddr_storage { uint8_t _padding128; };' >> $outfile fi cat >> $outfile <<\_______EOF diff --git a/libratbox/configure.ac b/libratbox/configure.ac index eb2b6207..86588c89 100644 --- a/libratbox/configure.ac +++ b/libratbox/configure.ac @@ -1,4 +1,4 @@ -dnl $Id: configure.ac 25574 2008-06-20 21:49:06Z androsyn $ +dnl $Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $ dnl Process this file with autoconf to produce a configure script. dnl TODO: clean up all the OpenSSL and shared module checking stuff; @@ -8,7 +8,7 @@ dnl said functions need to be just about as complex as they already are. AC_PREREQ(2.60) AUTOMAKE_OPTIONS = 1.10 dnl Sneaky way to get an Id tag into the configure script -AC_COPYRIGHT([$Id: configure.ac 25574 2008-06-20 21:49:06Z androsyn $]) +AC_COPYRIGHT([$Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $]) AC_INIT([libratbox],[devel]) AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION, -) @@ -99,20 +99,6 @@ if test "$libexecdir" = '${exec_prefix}/libexec' && localstatedir='${prefix}' fi -AC_TYPE_INT8_T -AC_TYPE_INT16_T -AC_TYPE_INT32_T -AC_TYPE_INT64_T -AC_TYPE_UINT8_T -AC_TYPE_UINT16_T -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T - -RB_TYPE_INTPTR_T -RB_TYPE_INTMAX_T -RB_TYPE_UINTMAX_T -RB_TYPE_UINTPTR_T - AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T @@ -144,21 +130,41 @@ member.])],,[[ #endif ]]) -AC_CHECK_TYPE(socklen_t, , -[AC_DEFINE([socklen_t], [unsigned int], -[If we don't have a real socklen_t, unsigned int is good enough.])], -[ -#ifdef HAVE_SYS_TYPES_H +AC_CHECK_TYPE([socklen_t], rb_socklen_t=socklen_t,[ + AC_MSG_CHECKING([for socklen_t equivalent]) + AC_CACHE_VAL([rb_socklen_t], + [ + # Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + rb_socklen_t= + for arg2 in "struct sockaddr" void; do + for t in int size_t unsigned long "unsigned long"; do + AC_TRY_COMPILE([ #include -#endif -#ifdef HAVE_SYS_SOCKET_H #include -#endif -#ifdef HAVE_WINSOCK2_H -#include -#endif +int getpeername (int, $arg2 *, $t *); +],[ +$t len; +getpeername(0,0,&len); +],[ + rb_socklen_t="$t" + break ]) + done + done + + if test "x$rb_socklen_t" = x; then + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) + fi + ]) + AC_MSG_RESULT($rb_socklen_t)], + [#include +#include ]) + + + + AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes]) @@ -218,7 +224,7 @@ AC_CHECK_TYPE([sa_family_t], [], dnl check for various functions... -AC_CHECK_FUNCS([socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl]) +AC_CHECK_FUNCS([socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage]) AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep])) AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create])) @@ -457,17 +463,6 @@ fi AC_SUBST(RB_PREFIX) -for dtype in uint64_t uint32_t uint16_t uint8_t int64_t int32_t int16_t int8_t intmax_t intptr_t uintmax_t uintptr_t -do - var="\$ac_cv_c_${dtype}" - t_type=$(eval echo $var); - if test "x$t_type" = "xyes"; then - eval rb_$dtype="\"$dtype\"" - else - eval rb_$dtype="\"$t_type\"" - fi -done - AC_CONFIG_COMMANDS([include/librb-config.h], [ outfile=include/librb-config.h.tmp @@ -552,28 +547,17 @@ if test "x$rb_errno_h" = "xyes"; then echo '#include ' >> $outfile fi +echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile + + if test "x$rb_sockaddr_sa_len" = "xyes"; then echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile fi -echo "typedef $rb_uint64_t rb_uint64_t;" >> $outfile -echo "typedef $rb_uint32_t rb_uint32_t;" >> $outfile -echo "typedef $rb_uint16_t rb_uint16_t;" >> $outfile -echo "typedef $rb_uint8_t rb_uint8_t;" >> $outfile -echo "typedef $rb_int64_t rb_int64_t;" >> $outfile -echo "typedef $rb_int32_t rb_int32_t;" >> $outfile -echo "typedef $rb_int16_t rb_int16_t;" >> $outfile -echo "typedef $rb_int8_t rb_int8_t;" >> $outfile -echo "typedef $rb_intmax_t rb_intmax_t;" >> $outfile -echo "typedef $rb_intptr_t rb_intptr_t;" >> $outfile -echo "typedef $rb_uintmax_t rb_uintmax_t;" >> $outfile -echo "typedef $rb_uintptr_t rb_uintptr_t;" >> $outfile -echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile - if test "x$rb_sockaddr_storage" = "xyes"; then echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile else - echo 'struct rb_sockaddr_storage { rb_uint8_t _padding[128]; };' >> $outfile + echo 'struct rb_sockaddr_storage { uint8_t _padding[128]; };' >> $outfile fi cat >> $outfile <<\_______EOF @@ -588,18 +572,6 @@ else fi ],[ - rb_uint64_t="$rb_uint64_t" - rb_uint32_t="$rb_uint32_t" - rb_uint16_t="$rb_uint16_t" - rb_uint8_t="$rb_uint8_t" - rb_int64_t="$rb_int64_t" - rb_int32_t="$rb_int32_t" - rb_int16_t="$rb_int16_t" - rb_int8_t="$rb_int8_t" - rb_intmax_t="$rb_intmax_t" - rb_intptr_t="$rb_intptr_t" - rb_uintmax_t="$rb_uintmax_t" - rb_uintptr_t="$rb_uintptr_t" if test x$ac_cv_header_stdc = xyes; then rb_header_stdc=yes fi @@ -661,11 +633,9 @@ fi if test x$ac_cv_header_winsock2_h = xyes; then rb_winsock2_h=yes fi - if test x$ac_cv_type_socklen_t = xyes; then - rb_socklen_t="socklen_t" - else - rb_socklen_t="unsigned int" - fi + + rb_socklen_t=$rb_socklen_t + if test "x$rb_have_sockaddr_storage" = "xyes"; then rb_sockaddr_storage="yes" else diff --git a/libratbox/include/arc4random.h b/libratbox/include/arc4random.h new file mode 100644 index 00000000..49e0a968 --- /dev/null +++ b/libratbox/include/arc4random.h @@ -0,0 +1,7 @@ + + +#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_ARC4RANDOM) +void arc4random_stir(void); +uint32_t arc4random(void); +void arc4random_addrandom(uint8_t *dat, int datlen); +#endif \ No newline at end of file diff --git a/libratbox/include/commio-int.h b/libratbox/include/commio-int.h index ad767dc9..d13d9eab 100644 --- a/libratbox/include/commio-int.h +++ b/libratbox/include/commio-int.h @@ -103,8 +103,8 @@ struct _fde */ rb_dlink_node node; int fd; /* So we can use the rb_fde_t as a callback ptr */ - rb_uint8_t flags; - rb_uint8_t type; + uint8_t flags; + uint8_t type; int pflags; char *desc; PF *read_handler; diff --git a/libratbox/include/commio-ssl.h b/libratbox/include/commio-ssl.h index 93aeab20..53921062 100644 --- a/libratbox/include/commio-ssl.h +++ b/libratbox/include/commio-ssl.h @@ -9,7 +9,7 @@ const char *rb_get_ssl_strerror(rb_fde_t *F); void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout); void rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout); void rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, struct sockaddr *clocal, int socklen, CNCB *callback, void *data, int timeout); -void rb_ssl_accept_setup(rb_fde_t *F, int new_fd, struct sockaddr *st, int addrlen); +void rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen); void rb_ssl_shutdown(rb_fde_t *F); ssize_t rb_ssl_read(rb_fde_t *F, void *buf, size_t count); ssize_t rb_ssl_write(rb_fde_t *F, const void *buf, size_t count); diff --git a/libratbox/include/libratbox_config.h.in b/libratbox/include/libratbox_config.h.in index 76b35017..3f4fd7f5 100644 --- a/libratbox/include/libratbox_config.h.in +++ b/libratbox/include/libratbox_config.h.in @@ -18,6 +18,9 @@ */ #undef HAVE_ALLOCA_H +/* Define to 1 if you have the `arc4random' function. */ +#undef HAVE_ARC4RANDOM + /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H @@ -45,6 +48,9 @@ /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE +/* Define to 1 if you have the `getrusage' function. */ +#undef HAVE_GETRUSAGE + /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY @@ -54,21 +60,12 @@ /* Has GnuTLS */ #undef HAVE_GNUTLS -/* Define to 1 if the system has the type `intmax_t'. */ -#undef HAVE_INTMAX_T - -/* Define to 1 if the system has the type `intptr_t'. */ -#undef HAVE_INTPTR_T - /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `kevent' function. */ #undef HAVE_KEVENT -/* Define to 1 if the system has the type `long long int'. */ -#undef HAVE_LONG_LONG_INT - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -183,18 +180,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H -/* Define to 1 if the system has the type `uintmax_t'. */ -#undef HAVE_UINTMAX_T - -/* Define to 1 if the system has the type `uintptr_t'. */ -#undef HAVE_UINTPTR_T - /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define to 1 if the system has the type `unsigned long long int'. */ -#undef HAVE_UNSIGNED_LONG_LONG_INT - /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP @@ -280,21 +268,6 @@ # undef _GNU_SOURCE #endif -/* Define for Solaris 2.5.1 so the uint32_t typedef from , - , or is not used. If the typedef was allowed, the - #define below would cause a syntax error. */ -#undef _UINT32_T - -/* Define for Solaris 2.5.1 so the uint64_t typedef from , - , or is not used. If the typedef was allowed, the - #define below would cause a syntax error. */ -#undef _UINT64_T - -/* Define for Solaris 2.5.1 so the uint8_t typedef from , - , or is not used. If the typedef was allowed, the - #define below would cause a syntax error. */ -#undef _UINT8_T - /* Define to empty if `const' does not conform to ANSI C. */ #undef const @@ -307,30 +280,6 @@ #undef inline #endif -/* Define to the type of a signed integer type of width exactly 16 bits if - such a type exists and the standard includes do not define it. */ -#undef int16_t - -/* Define to the type of a signed integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -#undef int32_t - -/* Define to the type of a signed integer type of width exactly 64 bits if - such a type exists and the standard includes do not define it. */ -#undef int64_t - -/* Define to the type of a signed integer type of width exactly 8 bits if such - a type exists and the standard includes do not define it. */ -#undef int8_t - -/* Define to the widest signed integer type if and do - not define. */ -#undef intmax_t - -/* Define to the type of a signed integer type wide enough to hold a pointer, - if such a type exists, and if the system does not define it. */ -#undef intptr_t - /* Define to `int' if does not define. */ #undef pid_t @@ -340,38 +289,11 @@ /* Define to `unsigned int' if does not define. */ #undef size_t -/* If we don't have a real socklen_t, unsigned int is good enough. */ -#undef socklen_t - /* Define to `int' if does not define. */ #undef ssize_t /* Define to `int' if doesn't define. */ #undef uid_t -/* Define to the type of an unsigned integer type of width exactly 16 bits if - such a type exists and the standard includes do not define it. */ -#undef uint16_t - -/* Define to the type of an unsigned integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -#undef uint32_t - -/* Define to the type of an unsigned integer type of width exactly 64 bits if - such a type exists and the standard includes do not define it. */ -#undef uint64_t - -/* Define to the type of an unsigned integer type of width exactly 8 bits if - such a type exists and the standard includes do not define it. */ -#undef uint8_t - -/* Define to the widest unsigned integer type if and - do not define. */ -#undef uintmax_t - -/* Define to the type of an unsigned integer type wide enough to hold a - pointer, if such a type exists, and if the system does not define it. */ -#undef uintptr_t - /* Define as `fork' if `vfork' does not work. */ #undef vfork diff --git a/libratbox/include/libratbox_config.h_vms b/libratbox/include/libratbox_config.h_vms new file mode 100755 index 00000000..633ab64c --- /dev/null +++ b/libratbox/include/libratbox_config.h_vms @@ -0,0 +1,374 @@ +/* include/libratbox_config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* This is a Cygwin system */ +#undef CYGWIN + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_CRYPT_H + +/* Define to 1 if you have devpoll */ +#undef HAVE_DEVPOLL + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the `epoll_ctl' function. */ +#undef HAVE_EPOLL_CTL + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + +/* Define to 1 if you have the `fstat' function. */ +#define HAVE_FSTAT 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* Define to 1 if the system has the type `intmax_t'. */ +#define HAVE_INTMAX_T 1 + +/* Define to 1 if the system has the type `intptr_t'. */ +#define HAVE_INTPTR_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `kevent' function. */ +#undef HAVE_KEVENT + +/* Define to 1 if the system has the type `long long int'. */ +#define HAVE_LONG_LONG_INT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have nanosleep */ +#define HAVE_NANOSLEEP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Has OpenSSL */ +#undef HAVE_OPENSSL + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the `port_create' function. */ +#undef HAVE_PORT_CREATE + +/* Define to 1 if you have the header file. */ +#undef HAVE_PORT_H + +/* Define to 1 if you have the `posix_spawn' function. */ +#define HAVE_POSIX_SPAWN 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sendmsg' function. */ +#define HAVE_SENDMSG 1 + +/* Define to 1 if you have the `signalfd' function. */ +#undef HAVE_SIGNALFD + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SPAWN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* 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 you have the `strnlen' function. */ +#define HAVE_STRNLEN 1 + +/* Define to 1 if you have the `strtok_r' function. */ +#define HAVE_STRTOK_R 1 + +/* Define to 1 if the system has the type `struct sockaddr_in6'. */ +#define HAVE_STRUCT_SOCKADDR_IN6 1 + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_DEVPOLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_EPOLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_EVENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_POLL_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SIGNALFD_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define if you have timer_create */ +#undef HAVE_TIMER_CREATE + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if the system has the type `uintmax_t'. */ +#define HAVE_UINTMAX_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if the system has the type `unsigned long long int'. */ +#define HAVE_UNSIGNED_LONG_LONG_INT 1 + +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFORK_H + +/* Define to 1 if you are on windows */ +#undef HAVE_WIN32 + +/* Define to 1 if `fork' works. */ +#undef HAVE_WORKING_FORK + +/* Define to 1 if `vfork' works. */ +#define HAVE_WORKING_VFORK 1 + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* This is a MinGW system */ +#undef MINGW + +/* Define this to disable debugging support. */ +#undef NDEBUG + +/* Define if your system needs crypt. */ +#undef NEED_CRYPT + +/* Define to 1 if you wish to disable the block allocator. */ +#undef NOBALLOC + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Defined to mark profiling is enabled */ +#undef RATBOX_PROFILE + +/* Prefix where libratbox is installed. */ +#define RB_PREFIX "/ratbox" + +/* Define to 1 if sockaddr has a 'sa_len' member. */ +#undef SOCKADDR_IN_HAS_LEN + +/* Define this to enable soft asserts. */ +#undef SOFT_ASSERT + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if we can use timer_create(CLOCK_REALTIME,...) */ +#undef USE_TIMER_CREATE + +/* This is a Windows system */ +#undef WINDOWS + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef was allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef was allowed, the + #define below would cause a syntax error. */ +#undef _UINT64_T + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef was allowed, the + #define below would cause a syntax error. */ +#undef _UINT8_T + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#define inline inline +#endif + +/* Define to the type of a signed integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +#undef int16_t + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef int32_t + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef int64_t + +/* Define to the type of a signed integer type of width exactly 8 bits if such + a type exists and the standard includes do not define it. */ +#undef int8_t + +/* Define to the widest signed integer type if and do + not define. */ +#undef intmax_t + +/* Define to the type of a signed integer type wide enough to hold a pointer, + if such a type exists, and if the system does not define it. */ +#undef intptr_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* If system does not define sa_family_t, define it here. */ +#undef sa_family_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* If we don't have a real socklen_t, unsigned int is good enough. */ +#undef socklen_t + +/* Define to `int' if does not define. */ +#undef ssize_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +#undef uint16_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef uint64_t + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +#undef uint8_t + +/* Define to the widest unsigned integer type if and + do not define. */ +#undef uintmax_t + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +#undef uintptr_t + +/* Define as `fork' if `vfork' does not work. */ +#define vfork fork diff --git a/libratbox/include/rb_commio.h b/libratbox/include/rb_commio.h index cff8d02d..9549aa50 100644 --- a/libratbox/include/rb_commio.h +++ b/libratbox/include/rb_commio.h @@ -21,7 +21,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_commio.h 25327 2008-05-08 19:32:13Z androsyn $ + * $Id: rb_commio.h 25693 2008-07-10 18:27:23Z androsyn $ */ #ifndef RB_LIB_H @@ -88,7 +88,7 @@ struct rb_iovec void rb_fdlist_init(int closeall, int maxfds, size_t heapsize); -rb_fde_t * rb_open(int, rb_uint8_t, const char *); +rb_fde_t * rb_open(int, uint8_t, const char *); void rb_close(rb_fde_t *); void rb_dump_fd(DUMPCB *, void *xdata); void rb_note(rb_fde_t *, const char *); @@ -148,8 +148,8 @@ rb_fde_t *rb_get_fde(int fd); int rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize); int rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int count); -void rb_set_type(rb_fde_t *F, rb_uint8_t type); -rb_uint8_t rb_get_type(rb_fde_t *F); +void rb_set_type(rb_fde_t *F, uint8_t type); +uint8_t rb_get_type(rb_fde_t *F); const char *rb_get_iotype(void); @@ -164,6 +164,7 @@ typedef enum { int rb_init_prng(const char *path, prng_seed_t seed_type); int rb_get_random(void *buf, size_t len); +int rb_get_pseudo_random(void *buf, size_t len); void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout); void rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout); int rb_supports_ssl(void); diff --git a/libratbox/include/rb_linebuf.h b/libratbox/include/rb_linebuf.h index 31b89c52..1d231e39 100644 --- a/libratbox/include/rb_linebuf.h +++ b/libratbox/include/rb_linebuf.h @@ -21,7 +21,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_linebuf.h 25227 2008-04-12 22:20:43Z jilles $ + * $Id: rb_linebuf.h 25675 2008-07-06 04:13:05Z androsyn $ */ #ifndef RB_LIB_H @@ -45,8 +45,8 @@ struct _buf_head; typedef struct _buf_line { char buf[BUF_DATA_SIZE + 2]; - rb_uint8_t terminated; /* Whether we've terminated the buffer */ - rb_uint8_t raw; /* Whether this linebuf may hold 8-bit data */ + uint8_t terminated; /* Whether we've terminated the buffer */ + uint8_t raw; /* Whether this linebuf may hold 8-bit data */ int len; /* How much data we've got */ int refcount; /* how many linked lists are we in? */ } buf_line_t; diff --git a/libratbox/src/Makefile.am b/libratbox/src/Makefile.am index 55b5fed3..03554349 100644 --- a/libratbox/src/Makefile.am +++ b/libratbox/src/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am 25532 2008-06-11 14:40:44Z androsyn $ +# $Id: Makefile.am 25689 2008-07-10 17:13:27Z androsyn $ AUTOMAKE_OPTIONS = foreign @@ -28,10 +28,11 @@ libratbox_la_SOURCES = \ select.c \ kqueue.c \ rawbuf.c \ - patricia.c + patricia.c \ + arc4random.c -libratbox_la_LDFLAGS = -version-info 3:0:0 -no-undefined -export-symbols export-syms.txt +libratbox_la_LDFLAGS = -avoid-version -no-undefined -export-symbols export-syms.txt libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@ lib_LTLIBRARIES = libratbox.la diff --git a/libratbox/src/Makefile.in b/libratbox/src/Makefile.in index 16738f9c..52d824e7 100644 --- a/libratbox/src/Makefile.in +++ b/libratbox/src/Makefile.in @@ -14,7 +14,7 @@ @SET_MAKE@ -# $Id: Makefile.am 25532 2008-06-11 14:40:44Z androsyn $ +# $Id: Makefile.am 25689 2008-07-10 17:13:27Z androsyn $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ @@ -58,7 +58,7 @@ am_libratbox_la_OBJECTS = unix.lo win32.lo crypt.lo balloc.lo \ commio.lo openssl.lo gnutls.lo nossl.lo event.lo ratbox_lib.lo \ rb_memory.lo linebuf.lo snprintf.lo tools.lo helper.lo \ devpoll.lo epoll.lo poll.lo ports.lo sigio.lo select.lo \ - kqueue.lo rawbuf.lo patricia.lo + kqueue.lo rawbuf.lo patricia.lo arc4random.lo libratbox_la_OBJECTS = $(am_libratbox_la_OBJECTS) libratbox_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -233,9 +233,10 @@ libratbox_la_SOURCES = \ select.c \ kqueue.c \ rawbuf.c \ - patricia.c + patricia.c \ + arc4random.c -libratbox_la_LDFLAGS = -version-info 3:0:0 -no-undefined -export-symbols export-syms.txt +libratbox_la_LDFLAGS = -avoid-version -no-undefined -export-symbols export-syms.txt libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@ lib_LTLIBRARIES = libratbox.la all: all-am @@ -307,6 +308,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc4random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/balloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt.Plo@am__quote@ diff --git a/libratbox/src/arc4random.c b/libratbox/src/arc4random.c new file mode 100644 index 00000000..534d2237 --- /dev/null +++ b/libratbox/src/arc4random.c @@ -0,0 +1,200 @@ +/* $Id: arc4random.c 25705 2008-07-11 18:21:57Z androsyn $ */ +/* $$$: arc4random.c 2005/02/08 robert */ +/* $NetBSD: arc4random.c,v 1.5.2.1 2004/03/26 22:52:50 jmc Exp $ */ +/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */ + +/* + * Arc4 random number generator for OpenBSD. + * Copyright 1996 David Mazieres . + * + * Modification and redistribution in source and binary forms is + * permitted provided that due credit is given to the author and the + * OpenBSD project by leaving this copyright notice intact. + */ + +/* + * This code is derived from section 17.1 of Applied Cryptography, + * second edition, which describes a stream cipher allegedly + * compatible with RSA Labs "RC4" cipher (the actual description of + * which is a trade secret). The same algorithm is used as a stream + * cipher called "arcfour" in Tatu Ylonen's ssh package. + * + * Here the stream cipher has been modified always to include the time + * when initializing the state. That makes it impossible to + * regenerate the same random sequence twice, so this can't be used + * for encryption, but will generate good random numbers. + * + * RC4 is a registered trademark of RSA Laboratories. + */ + + +#include +#include + +#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_ARC4RANDOM) + +#include "arc4random.h" + +#ifdef HAVE_GETRUSAGE +#include +#endif + + + +struct arc4_stream { + uint8_t i; + uint8_t j; + uint8_t s[256]; +}; + + +static int rs_initialized; +static struct arc4_stream rs; + +static inline void arc4_init(struct arc4_stream *); +static inline void arc4_addrandom(struct arc4_stream *, uint8_t *, int); +static void arc4_stir(struct arc4_stream *); +static inline uint8_t arc4_getbyte(struct arc4_stream *); +static inline uint32_t arc4_getword(struct arc4_stream *); + +static inline void +arc4_init(struct arc4_stream *as) +{ + int n; + + for (n = 0; n < 256; n++) + as->s[n] = n; + as->i = 0; + as->j = 0; +} + +static inline void +arc4_addrandom(struct arc4_stream *as, uint8_t *dat, int datlen) +{ + int n; + uint8_t si; + + as->i--; + for (n = 0; n < 256; n++) { + as->i = (as->i + 1); + si = as->s[as->i]; + as->j = (as->j + si + dat[n % datlen]); + as->s[as->i] = as->s[as->j]; + as->s[as->j] = si; + } + as->j = as->i; +} + +static void +arc4_stir(struct arc4_stream *as) +{ + struct timeval tv; + pid_t pid; + int n; + /* XXX this doesn't support egd sources or similiar */ + + pid = getpid(); + arc4_addrandom(as, (void *)&pid, sizeof(pid)); + + rb_gettimeofday(&tv, NULL); + arc4_addrandom(as, (void *)&tv.tv_sec, sizeof(&tv.tv_sec)); + arc4_addrandom(as, (void *)&tv.tv_usec, sizeof(&tv.tv_usec)); + rb_gettimeofday(&tv, NULL); + arc4_addrandom(as, (void *)&tv.tv_usec, sizeof(&tv.tv_usec)); + +#if defined(HAVE_GETRUSAGE) && RUSAGE_SELF + { + struct rusage buf; + getrusage(RUSAGE_SELF, &buf); + arc4_addrandom(as, (void *)&buf, sizeof(buf)); + memset(&buf, 0, sizeof(buf)) + } +#endif + +#if !defined(WIN32) + { + uint8_t rnd[128]; + int fd; + fd = open("/dev/urandom", O_RDONLY); + if (fd != -1) + { + read(fd, rnd, sizeof(rnd)); + close(fd); + arc4_addrandom(as, (void *)rnd, sizeof(rnd)); + } + } +#else + { + LARGE_INTEGER performanceCount; + if (QueryPerformanceCounter (&performanceCount)) + { + arc4_addrandom(as, (void *)&performanceCount, sizeof(performanceCount)); + } + } +#endif + + + /* + * Throw away the first N words of output, as suggested in the + * paper "Weaknesses in the Key Scheduling Algorithm of RC4" + * by Fluher, Mantin, and Shamir. + * http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps + * N = 256 in our case. + */ + for (n = 0; n < 256 * 4; n++) + arc4_getbyte(as); +} + +static inline uint8_t +arc4_getbyte(struct arc4_stream *as) +{ + uint8_t si, sj; + + as->i = (as->i + 1); + si = as->s[as->i]; + as->j = (as->j + si); + sj = as->s[as->j]; + as->s[as->i] = sj; + as->s[as->j] = si; + return (as->s[(si + sj) & 0xff]); +} + +static inline uint32_t +arc4_getword(struct arc4_stream *as) +{ + uint32_t val; + val = arc4_getbyte(as) << 24; + val |= arc4_getbyte(as) << 16; + val |= arc4_getbyte(as) << 8; + val |= arc4_getbyte(as); + return val; +} + +void +arc4random_stir(void) +{ + if (!rs_initialized) { + arc4_init(&rs); + rs_initialized = 1; + } + arc4_stir(&rs); +} + +void +arc4random_addrandom(uint8_t *dat, int datlen) +{ + if (!rs_initialized) + arc4random_stir(); + arc4_addrandom(&rs, dat, datlen); +} + +uint32_t +arc4random(void) +{ + if (!rs_initialized) + arc4random_stir(); + return arc4_getword(&rs); +} + +#endif + diff --git a/libratbox/src/balloc.c b/libratbox/src/balloc.c index 86d521ef..19e9a256 100644 --- a/libratbox/src/balloc.c +++ b/libratbox/src/balloc.c @@ -28,7 +28,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: balloc.c 25375 2008-05-16 15:19:51Z androsyn $ + * $Id: balloc.c 25675 2008-07-06 04:13:05Z androsyn $ */ /* @@ -225,7 +225,7 @@ newblock(rb_bh * bh) { rb_heap_block *b; unsigned long i; - rb_uintptr_t offset; + uintptr_t offset; /* Setup the initial data structure. */ b = rb_malloc(sizeof(rb_heap_block)); @@ -237,7 +237,7 @@ newblock(rb_bh * bh) { return (1); } - offset = (rb_uintptr_t)b->elems; + offset = (uintptr_t)b->elems; /* Setup our blocks now */ for (i = 0; i < bh->elemsPerBlock; i++, offset += (bh->elemSize + sizeof(rb_heap_block *))) { diff --git a/libratbox/src/commio.c b/libratbox/src/commio.c index 5f677289..59eb02dd 100644 --- a/libratbox/src/commio.c +++ b/libratbox/src/commio.c @@ -21,7 +21,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: commio.c 25375 2008-05-16 15:19:51Z androsyn $ + * $Id: commio.c 25795 2008-07-29 15:26:55Z androsyn $ */ #include #include @@ -80,7 +80,6 @@ static inline rb_fde_t * add_fd(int fd) { rb_fde_t *F = rb_find_fd(fd); - rb_dlink_list *list; /* look up to see if we have it already */ if(F != NULL) @@ -88,21 +87,17 @@ add_fd(int fd) F = rb_bh_alloc(fd_heap); F->fd = fd; - list = &rb_fd_table[rb_hash_fd(fd)]; - rb_dlinkAdd(F, &F->node, list); + rb_dlinkAdd(F, &F->node, &rb_fd_table[rb_hash_fd(fd)]); return(F); } static inline void remove_fd(rb_fde_t *F) { - rb_dlink_list *list; - if(F == NULL || !IsFDOpen(F)) return; - list = &rb_fd_table[rb_hash_fd(F->fd)]; - rb_dlinkMoveNode(&F->node, list, &closed_list); + rb_dlinkMoveNode(&F->node, &rb_fd_table[rb_hash_fd(F->fd)], &closed_list); } static void @@ -368,6 +363,13 @@ rb_accept_tryaccept(rb_fde_t *F, void *data) new_F = rb_open(new_fd, RB_FD_SOCKET, "Incoming Connection"); + if(new_F == NULL) + { + rb_lib_log("rb_accept: new_F == NULL on incoming connection. Closing new_fd == %d\n", new_fd); + close(new_fd); + continue; + } + if(rb_unlikely(!rb_set_nb(new_F))) { rb_get_errno(); @@ -387,7 +389,7 @@ rb_accept_tryaccept(rb_fde_t *F, void *data) #ifdef HAVE_SSL if(F->type & RB_FD_SSL) { - rb_ssl_accept_setup(F, new_fd, (struct sockaddr *)&st, addrlen); + rb_ssl_accept_setup(F, new_F, (struct sockaddr *)&st, addrlen); } else #endif /* HAVE_SSL */ @@ -715,8 +717,11 @@ rb_socket(int family, int sock_type, int proto, const char *note) F = rb_open(fd, RB_FD_SOCKET, note); if(F == NULL) + { + rb_lib_log("rb_socket: rb_open returns NULL on FD %d: %s, closing fd", fd, strerror(errno)); + close(fd); return NULL; - + } /* Set the socket non-blocking, and other wonderful bits */ if(rb_unlikely(!rb_set_nb(F))) { @@ -747,7 +752,7 @@ mangle_mapped_sockaddr(struct sockaddr *in) memset(&in4, 0, sizeof(struct sockaddr_in)); in4.sin_family = AF_INET; in4.sin_port = in6->sin6_port; - in4.sin_addr.s_addr = ((rb_uint32_t *) & in6->sin6_addr)[3]; + in4.sin_addr.s_addr = ((uint32_t *) & in6->sin6_addr)[3]; memcpy(in, &in4, sizeof(struct sockaddr_in)); } return; @@ -796,16 +801,24 @@ rb_fdlist_init(int closeall, int maxfds, size_t heapsize) /* Called to open a given filedescriptor */ rb_fde_t * -rb_open(int fd, rb_uint8_t type, const char *desc) +rb_open(int fd, uint8_t type, const char *desc) { - rb_fde_t *F = add_fd(fd); + rb_fde_t *F; lrb_assert(fd >= 0); + F = add_fd(fd); + + lrb_assert(!IsFDOpen(F)); if(rb_unlikely(IsFDOpen(F))) { + const char *fdesc; + if(F != NULL && F->desc != NULL) + fdesc = F->desc; + else + fdesc = "NULL"; + rb_lib_log("Trying to rb_open an already open FD: %d desc: %d", fd, fdesc); return NULL; } - lrb_assert(!IsFDOpen(F)); F->fd = fd; F->type = type; SetFDOpen(F); @@ -913,14 +926,14 @@ rb_note(rb_fde_t *F, const char *string) } void -rb_set_type(rb_fde_t *F, rb_uint8_t type) +rb_set_type(rb_fde_t *F, uint8_t type) { /* if the caller is calling this, lets assume they have a clue */ F->type = type; return; } -rb_uint8_t +uint8_t rb_get_type(rb_fde_t *F) { return F->type; @@ -2002,7 +2015,7 @@ rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds struct cmsghdr *cmsg; struct iovec iov[1]; struct stat st; - rb_uint8_t stype = RB_FD_UNKNOWN; + uint8_t stype = RB_FD_UNKNOWN; const char *desc; int fd, len, x, rfds; diff --git a/libratbox/src/crypt.c b/libratbox/src/crypt.c index 5088bfe6..58e054ba 100644 --- a/libratbox/src/crypt.c +++ b/libratbox/src/crypt.c @@ -110,7 +110,7 @@ rb_crypt(const char *key, const char *salt) * * ARCHITECTURE ASSUMPTIONS: * It is assumed that the 8-byte arrays passed by reference can be - * addressed as arrays of rb_uint32_t's (ie. the CPU is not picky about + * addressed as arrays of uint32_t's (ie. the CPU is not picky about * alignment). */ @@ -121,15 +121,15 @@ static u_char inv_key_perm[64]; static u_char inv_comp_perm[56]; static u_char u_sbox[8][64]; static u_char un_pbox[32]; -static rb_uint32_t en_keysl[16], en_keysr[16]; -static rb_uint32_t de_keysl[16], de_keysr[16]; -static rb_uint32_t ip_maskl[8][256], ip_maskr[8][256]; -static rb_uint32_t fp_maskl[8][256], fp_maskr[8][256]; -static rb_uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128]; -static rb_uint32_t comp_maskl[8][128], comp_maskr[8][128]; -static rb_uint32_t saltbits; -static rb_uint32_t old_salt; -static rb_uint32_t old_rawkey0, old_rawkey1; +static uint32_t en_keysl[16], en_keysr[16]; +static uint32_t de_keysl[16], de_keysr[16]; +static uint32_t ip_maskl[8][256], ip_maskr[8][256]; +static uint32_t fp_maskl[8][256], fp_maskr[8][256]; +static uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128]; +static uint32_t comp_maskl[8][128], comp_maskr[8][128]; +static uint32_t saltbits; +static uint32_t old_salt; +static uint32_t old_rawkey0, old_rawkey1; /* Static stuff that stays resident and doesn't change after @@ -137,7 +137,7 @@ static rb_uint32_t old_rawkey0, old_rawkey1; * reentrant. */ static u_char init_perm[64], final_perm[64]; static u_char m_sbox[4][4096]; -static rb_uint32_t psbox[4][256]; +static uint32_t psbox[4][256]; @@ -230,7 +230,7 @@ static const u_char pbox[32] = { 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; -static const rb_uint32_t bits32[32] = +static const uint32_t bits32[32] = { 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000, 0x01000000, @@ -243,7 +243,7 @@ static const rb_uint32_t bits32[32] = }; static const u_char bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; -static const rb_uint32_t *bits28, *bits24; +static const uint32_t *bits28, *bits24; static int @@ -268,7 +268,7 @@ static void des_init(void) { int i, j, b, k, inbit, obit; - rb_uint32_t *p, *il, *ir, *fl, *fr; + uint32_t *p, *il, *ir, *fl, *fr; static int des_initialised = 0; if (des_initialised==1) @@ -401,7 +401,7 @@ des_init(void) static void setup_salt(long salt) { - rb_uint32_t obit, saltbit; + uint32_t obit, saltbit; int i; if (salt == (long)old_salt) @@ -423,13 +423,13 @@ setup_salt(long salt) static int des_setkey(const char *key) { - rb_uint32_t k0, k1, rawkey0, rawkey1; + uint32_t k0, k1, rawkey0, rawkey1; int shifts, round; des_init(); - rawkey0 = ntohl(*(const rb_uint32_t *) key); - rawkey1 = ntohl(*(const rb_uint32_t *) (key + 4)); + rawkey0 = ntohl(*(const uint32_t *) key); + rawkey1 = ntohl(*(const uint32_t *) (key + 4)); if ((rawkey0 | rawkey1) && rawkey0 == old_rawkey0 @@ -469,7 +469,7 @@ des_setkey(const char *key) */ shifts = 0; for (round = 0; round < 16; round++) { - rb_uint32_t t0, t1; + uint32_t t0, t1; shifts += key_shifts[round]; @@ -501,13 +501,13 @@ des_setkey(const char *key) static int -do_des( rb_uint32_t l_in, rb_uint32_t r_in, rb_uint32_t *l_out, rb_uint32_t *r_out, int count) +do_des( uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint32_t *r_out, int count) { /* * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. */ - rb_uint32_t l, r, *kl, *kr, *kl1, *kr1; - rb_uint32_t f, r48l, r48r; + uint32_t l, r, *kl, *kr, *kl1, *kr1; + uint32_t f, r48l, r48r; int round; if (count == 0) { @@ -619,12 +619,12 @@ do_des( rb_uint32_t l_in, rb_uint32_t r_in, rb_uint32_t *l_out, rb_uint32_t *r_o #if 0 static int -des_cipher(const char *in, char *out, rb_uint32_t salt, int count) +des_cipher(const char *in, char *out, uint32_t salt, int count) { - rb_uint32_t l_out, r_out, rawl, rawr; + uint32_t l_out, r_out, rawl, rawr; int retval; union { - rb_uint32_t *ui32; + uint32_t *ui32; const char *c; } trans; @@ -650,7 +650,7 @@ void setkey(const char *key) { int i, j; - rb_uint32_t packed_keys[2]; + uint32_t packed_keys[2]; u_char *p; p = (u_char *) packed_keys; @@ -668,7 +668,7 @@ setkey(const char *key) void encrypt(char *block, int flag) { - rb_uint32_t io[2]; + uint32_t io[2]; u_char *p; int i, j; @@ -692,7 +692,7 @@ encrypt(char *block, int flag) static char * __des_crypt(const char *key, const char *setting) { - rb_uint32_t count, salt, l, r0, r1, keybuf[2]; + uint32_t count, salt, l, r0, r1, keybuf[2]; u_char *p, *q; static char output[21]; @@ -885,8 +885,8 @@ __des_crypt(const char *key, const char *setting) /* MD5 context. */ struct MD5Context { - rb_uint32_t state[4]; /* state (ABCD) */ - rb_uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ }; @@ -894,7 +894,7 @@ static void __md5_Init (struct MD5Context *); static void __md5_Update (struct MD5Context *, const char *, unsigned int); static void __md5_Pad (struct MD5Context *); static void __md5_Final (char [16], struct MD5Context *); -static void __md5_Transform (rb_uint32_t [4], const unsigned char [64]); +static void __md5_Transform (uint32_t [4], const unsigned char [64]); static const char __md5__magic[] = "$1$"; /* This string is magic for this algorithm. Having @@ -910,12 +910,12 @@ static const unsigned char __md5_itoa64[] = /* 0 ... 63 => ascii - 64 */ #else /* i386 */ /* - * __md5_Encodes input (rb_uint32_t) into output (unsigned char). Assumes len is + * __md5_Encodes input (uint32_t) into output (unsigned char). Assumes len is * a multiple of 4. */ static void -__md5_Encode (unsigned char *output, rb_uint32_t *input, unsigned int len) +__md5_Encode (unsigned char *output, uint32_t *input, unsigned int len) { unsigned int i, j; @@ -928,18 +928,18 @@ __md5_Encode (unsigned char *output, rb_uint32_t *input, unsigned int len) } /* - * __md5_Decodes input (unsigned char) into output (rb_uint32_t). Assumes len is + * __md5_Decodes input (unsigned char) into output (uint32_t). Assumes len is * a multiple of 4. */ static void -__md5_Decode (rb_uint32_t *output, const unsigned char *input, unsigned int len) +__md5_Decode (uint32_t *output, const unsigned char *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((rb_uint32_t)input[j]) | (((rb_uint32_t)input[j+1]) << 8) | - (((rb_uint32_t)input[j+2]) << 16) | (((rb_uint32_t)input[j+3]) << 24); + output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) | + (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24); } #endif /* i386 */ @@ -957,22 +957,22 @@ __md5_Decode (rb_uint32_t *output, const unsigned char *input, unsigned int len) * Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \ + (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \ + (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \ + (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \ + (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } @@ -1004,10 +1004,10 @@ static void __md5_Update ( struct MD5Context *context, const char *xinput, unsig lindex = (unsigned int)((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((rb_uint32_t)inputLen << 3)) - < ((rb_uint32_t)inputLen << 3)) + if ((context->count[0] += ((uint32_t)inputLen << 3)) + < ((uint32_t)inputLen << 3)) context->count[1]++; - context->count[1] += ((rb_uint32_t)inputLen >> 29); + context->count[1] += ((uint32_t)inputLen >> 29); partLen = 64 - lindex; @@ -1077,13 +1077,13 @@ static void __md5_Final ( char xdigest[16], struct MD5Context *context) static void __md5_Transform (state, block) - rb_uint32_t state[4]; + uint32_t state[4]; const unsigned char block[64]; { - rb_uint32_t a, b, c, d, x[16]; + uint32_t a, b, c, d, x[16]; #if MD5_SIZE_OVER_SPEED > 1 - rb_uint32_t temp; + uint32_t temp; const char *ps; static const char S[] = { @@ -1095,11 +1095,11 @@ __md5_Transform (state, block) #endif /* MD5_SIZE_OVER_SPEED > 1 */ #if MD5_SIZE_OVER_SPEED > 0 - const rb_uint32_t *pc; + const uint32_t *pc; const char *pp; int i; - static const rb_uint32_t C[] = { + static const uint32_t C[] = { /* round 1 */ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, diff --git a/libratbox/src/descrip.mms b/libratbox/src/descrip.mms new file mode 100644 index 00000000..1c61ad7d --- /dev/null +++ b/libratbox/src/descrip.mms @@ -0,0 +1,10 @@ +CFLAGS= /INCLUDE=([-.INCLUDE])/ERROR_LIMIT=5/DEFINE=(_XOPEN_SOURCE_EXTENDED)/NOANSI_ALIAS +OBJECTS= balloc.obj, commio.obj, crypt.obj, event.obj, - + helper.obj, linebuf.obj, nossl.obj, patricia.obj, - + poll.obj, ratbox_lib.obj, rawbuf.obj, rb_memory.obj, - + snprintf.obj, tools.obj, unix.obj + +DEFAULT : RATBOX.OLB($(OBJECTS)) + +CLEAN : + - DELETE *.OBJ;*, *.OLB;* diff --git a/libratbox/src/epoll.c b/libratbox/src/epoll.c index 25d68b9b..1f995683 100644 --- a/libratbox/src/epoll.c +++ b/libratbox/src/epoll.c @@ -23,7 +23,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: epoll.c 25038 2008-01-23 16:03:08Z androsyn $ + * $Id: epoll.c 25675 2008-07-06 04:13:05Z androsyn $ */ #define _GNU_SOURCE 1 @@ -282,23 +282,23 @@ rb_epoll_supports_event(void) /* bleh..work around a glibc header bug on 32bit systems */ struct our_signalfd_siginfo { - rb_uint32_t signo; - rb_int32_t err; - rb_int32_t code; - rb_uint32_t pid; - rb_uint32_t uid; - rb_int32_t fd; - rb_uint32_t tid; - rb_uint32_t band; - rb_uint32_t overrun; - rb_uint32_t trapno; - rb_int32_t status; - rb_int32_t svint; - rb_uint64_t svptr; - rb_uint64_t utime; - rb_uint64_t stime; - rb_uint64_t addr; - rb_uint8_t pad[48]; + uint32_t signo; + int32_t err; + int32_t code; + uint32_t pid; + uint32_t uid; + int32_t fd; + uint32_t tid; + uint32_t band; + uint32_t overrun; + uint32_t trapno; + int32_t status; + int32_t svint; + uint64_t svptr; + uint64_t utime; + uint64_t stime; + uint64_t addr; + uint8_t pad[48]; }; diff --git a/libratbox/src/export-syms.txt b/libratbox/src/export-syms.txt index 378a44db..d7428503 100644 --- a/libratbox/src/export-syms.txt +++ b/libratbox/src/export-syms.txt @@ -145,3 +145,4 @@ rb_spawn_process rb_supports_ssl rb_ssl_handshake_count rb_ssl_clear_handshake_count +rb_get_pseudo_random diff --git a/libratbox/src/gnutls.c b/libratbox/src/gnutls.c index cd279b35..217dc54d 100644 --- a/libratbox/src/gnutls.c +++ b/libratbox/src/gnutls.c @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: gnutls.c 25568 2008-06-20 18:46:08Z androsyn $ + * $Id: gnutls.c 25793 2008-07-29 14:47:48Z androsyn $ */ #include @@ -164,11 +164,8 @@ rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout) void -rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen) +rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen) { - rb_fde_t *new_F; - - new_F = rb_find_fd(new_fd); new_F->type |= RB_FD_SSL; new_F->ssl = rb_malloc(sizeof(gnutls_session_t)); new_F->accept = rb_malloc(sizeof(struct acceptdata)); @@ -183,7 +180,7 @@ rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen) gnutls_set_default_priority(SSL_P(new_F)); gnutls_credentials_set(SSL_P(new_F), GNUTLS_CRD_CERTIFICATE, x509); gnutls_dh_set_prime_bits(SSL_P(new_F), 1024); - gnutls_transport_set_ptr(SSL_P(new_F), (gnutls_transport_ptr_t) (long int)new_fd); + gnutls_transport_set_ptr(SSL_P(new_F), (gnutls_transport_ptr_t) (long int)rb_get_fd(new_F)); if(do_ssl_handshake(F, rb_ssl_tryaccept)) { struct acceptdata *ad = F->accept; @@ -485,6 +482,12 @@ rb_get_random(void *buf, size_t length) return 1; } +int +rb_get_pseudo_random(void *buf, size_t length) +{ + gcry_randomize(buf, length, GCRY_WEAK_RANDOM); + return 1; +} const char * rb_get_ssl_strerror(rb_fde_t * F) diff --git a/libratbox/src/nossl.c b/libratbox/src/nossl.c index eed302e1..f3758c5e 100644 --- a/libratbox/src/nossl.c +++ b/libratbox/src/nossl.c @@ -26,9 +26,10 @@ #include #include - #if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) +#include "arc4random.h" + #include #include @@ -54,17 +55,43 @@ rb_ssl_listen(rb_fde_t *F, int backlog) return -1; } +static void +rb_stir_arc4random(void *unused) +{ + arc4random_stir(); +} + + int rb_init_prng(const char *path, prng_seed_t seed_type) { - return -1; + /* xxx this ignores the parameters above */ + arc4random_stir(); + rb_event_addish("rb_stir_arc4random", rb_stir_arc4random, NULL, 300); + return 1; } int rb_get_random(void *buf, size_t length) { - return -1; + uint32_t rnd = 0, i; + uint8_t *xbuf = buf; + for (i = 0; i < sizeof(length); i++) + { + if(i % 4 == 0) + rnd = arc4random(); + xbuf[i] = rnd; + rnd >>= 8; + } + return 1; } +int +rb_get_pseudo_random(void *buf, size_t length) +{ + return rb_get_random(buf, length); +} + + const char * rb_get_ssl_strerror(rb_fde_t *F) { @@ -104,7 +131,7 @@ rb_ssl_shutdown(rb_fde_t * F) } void -rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen) +rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen) { return; } diff --git a/libratbox/src/openssl.c b/libratbox/src/openssl.c index 9188c442..d8efaa7b 100644 --- a/libratbox/src/openssl.c +++ b/libratbox/src/openssl.c @@ -204,13 +204,8 @@ rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout) void -rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen) +rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen) { - rb_fde_t *new_F; - - new_F = rb_find_fd(new_fd); - if(new_F == NULL) - return; new_F->type |= RB_FD_SSL; new_F->ssl = SSL_new(ssl_server_ctx); new_F->accept = rb_malloc(sizeof(struct acceptdata)); @@ -221,7 +216,7 @@ rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen) memcpy(&new_F->accept->S, st, addrlen); new_F->accept->addrlen = addrlen; - SSL_set_fd((SSL *) new_F->ssl, new_fd); + SSL_set_fd((SSL *) new_F->ssl, rb_get_fd(new_F)); rb_setup_ssl_cb(new_F); rb_ssl_accept_common(new_F); } @@ -578,19 +573,25 @@ rb_init_prng(const char *path, prng_seed_t seed_type) int rb_get_random(void *buf, size_t length) { - if(RAND_status()) + int ret; + + if((ret = RAND_bytes(buf, length)) == 0) { - if(RAND_bytes(buf, length) > 0) - return 1; + /* remove the error from the queue */ + ERR_get_error(); } - else - { - if(RAND_pseudo_bytes(buf, length) >= 0) - return 1; - } - return 0; + return ret; } +int +rb_get_pseudo_random(void *buf, size_t length) +{ + int ret; + ret = RAND_pseudo_bytes(buf, length); + if(ret < 0) + return 0; + return 1; +} const char * rb_get_ssl_strerror(rb_fde_t * F) diff --git a/libratbox/src/rawbuf.c b/libratbox/src/rawbuf.c index 6a53acb0..edc29584 100644 --- a/libratbox/src/rawbuf.c +++ b/libratbox/src/rawbuf.c @@ -30,9 +30,9 @@ struct _rawbuf { rb_dlink_node node; - rb_uint8_t data[RAWBUF_SIZE]; + uint8_t data[RAWBUF_SIZE]; int len; - rb_uint8_t flushing; + uint8_t flushing; }; struct _rawbuf_head