diff --git a/Makefile.am b/Makefile.am index 4065c0d2..34d13533 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,11 +16,11 @@ if PLUGIN SUBDIRS += src/ulib/net/server/plugin src/ulib/orm/driver endif if ENABLE_EXAMPLES -SUBDIRS += examples contrib +SUBDIRS += examples endif SUBDIRS += tests -DIST_SUBDIRS = include src/ulib src/ulib/net/server/plugin src/ulib/orm/driver m4 doc contrib examples tests +DIST_SUBDIRS = include src/ulib src/ulib/net/server/plugin src/ulib/orm/driver m4 doc examples tests contrib ## bin_SCRIPTS = ulib-config diff --git a/Makefile.in b/Makefile.in index eb53b20e..f5515fc9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -90,7 +90,7 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ @PLUGIN_TRUE@am__append_1 = src/ulib/net/server/plugin src/ulib/orm/driver -@ENABLE_EXAMPLES_TRUE@am__append_2 = examples contrib +@ENABLE_EXAMPLES_TRUE@am__append_2 = examples subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_package.m4 \ @@ -449,7 +449,7 @@ EXTRA_DIST = cdb configure.help TODO LICENSE* README* *.spec* \ MAINTAINERCLEANFILES = configure aclocal.m4 libtool Makefile.in Makefile INSTALL moduledir = @ULIB_MODULEDIR@ SUBDIRS = include src/ulib $(am__append_1) $(am__append_2) tests -DIST_SUBDIRS = include src/ulib src/ulib/net/server/plugin src/ulib/orm/driver m4 doc contrib examples tests +DIST_SUBDIRS = include src/ulib src/ulib/net/server/plugin src/ulib/orm/driver m4 doc examples tests contrib aclocaldir = $(datadir)/aclocal aclocal_DATA = ULib.m4 all: all-recursive diff --git a/configure b/configure index ba4bcac8..0c3a2316 100755 --- a/configure +++ b/configure @@ -1056,16 +1056,16 @@ with_parser with_distcc with_libz enable_zip -with_libtdb with_libzopfli with_magic with_ssl with_pcre with_expat with_libuuid +with_curl +with_libtdb with_libares with_ssh -with_curl with_ldap with_dbi with_libevent @@ -1817,16 +1817,16 @@ Optional Packages: --with-parser use parser generator bison/yacc --with-distcc using distcc we must avoid to use some gcc flags (-mtune=native,-flto,...) --with-libz use system LIBZ library - [will check /usr /usr/local] [default=use if present] - --with-libtdb use system tdb library - [will check /usr /usr/local] [default=use if present] --with-libzopfli use system zopfli library - [will check /usr /usr/local] [default=use if present] --with-magic use system libmagic library - [will check /usr /usr/local] [default=use if present] --with-ssl use system SSL library - [will check /usr /usr/local] [default=use if present] --with-pcre use system PCRE library - [will check /usr /usr/local] [default=use if present] --with-expat use system EXPAT library - [will check /usr /usr/local] [default=use if present] - --with-libuuid use system libuuid library - [will check /usr /usr/local] + --with-libuuid use system libuuid library - [will check /usr /usr/local] [default=use if present] + --with-curl use system cURL library - [will check /usr /usr/local] + --with-libtdb use system tdb library - [will check /usr /usr/local] --with-libares use system c-ares library - [will check /usr /usr/local] --with-ssh use system SSH library - [will check /usr /usr/local] - --with-curl use system cURL library - [will check /usr /usr/local] --with-ldap use system openLDAP library - [will check /usr /usr/local] --with-dbi use system DBI library - [will check /usr /usr/local] --with-libevent use system libevent library - [will check /usr /usr/local] @@ -26974,7 +26974,11 @@ $as_echo_n "checking if LIBZ library is wanted... " >&6; } wanted=1; if test -z "$with_libz" ; then wanted=0; - with_libz="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" ; then + with_libz="no"; + else + with_libz="${CROSS_ENVIRONMENT}/usr"; + fi fi # Check whether --with-libz was given. @@ -27028,86 +27032,27 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to enable build of ZIP support" >&5 $as_echo_n "checking if you want to enable build of ZIP support... " >&6; } + if test x_$found_libz = x_yes; then + if test -z "$enable_zip" -o x_$enable_zip != x_no; then + enable_zip="yes" + fi + else + enable_zip="no" + fi # Check whether --enable-zip was given. if test "${enable_zip+set}" = set; then : enableval=$enable_zip; fi - if test "$enable_zip" != "no" -a x_$found_libz = x_yes; then - enable_zip="yes" - else - enable_zip="no" - fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_zip" >&5 $as_echo "$enable_zip" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if tdb library is wanted" >&5 -$as_echo_n "checking if tdb library is wanted... " >&6; } - wanted=1; - if test -z "$with_libtdb" ; then - wanted=0; - if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then - with_libtdb="no"; - else - with_libtdb="${CROSS_ENVIRONMENT}/usr"; - fi - fi - -# Check whether --with-libtdb was given. -if test "${with_libtdb+set}" = set; then : - withval=$with_libtdb; - if test "$withval" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do - libtdbdir="$dir" - if test -f "$dir/include/tdb.h"; then - found_libtdb="yes"; - break; - fi - done - if test x_$found_libtdb != x_yes; then - msg="Cannot find libtdb library"; - if test $wanted = 1; then - as_fn_error $? "$msg" "$LINENO" 5 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5 -$as_echo "$msg" >&6; } - fi - else - echo "${T_MD}libtdb found in $libtdbdir${T_ME}" - USE_LIBTDB=yes - -$as_echo "#define USE_LIBTDB 1" >>confdefs.h - - libtdb_version=$(ls $libtdbdir/lib*/libtdb.so.*.* 2>/dev/null | head -n 1 | awk -F'.so.' '{n=2; print $n}' 2>/dev/null) - if test -z "${libtdb_version}"; then - libtdb_version="unknown" - fi - ULIB_LIBS="$ULIB_LIBS -ltdb"; - if test $libtdbdir != "${CROSS_ENVIRONMENT}/" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr/local"; then - CPPFLAGS="$CPPFLAGS -I$libtdbdir/include" - LDFLAGS="$LDFLAGS -L$libtdbdir/lib -Wl,-R$libtdbdir/lib"; - PRG_LDFLAGS="$PRG_LDFLAGS -L$libtdbdir/lib"; - fi - fi - fi - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if zopfli library is wanted" >&5 $as_echo_n "checking if zopfli library is wanted... " >&6; } wanted=1; if test -z "$with_libzopfli" ; then wanted=0; - if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then with_libzopfli="no"; else with_libzopfli="${CROSS_ENVIRONMENT}/usr"; @@ -27168,7 +27113,11 @@ $as_echo_n "checking if MAGIC library is wanted... " >&6; } wanted=1; if test -z "$with_magic" ; then wanted=0; - with_magic="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_magic="no"; + else + with_magic="${CROSS_ENVIRONMENT}/usr"; + fi fi # Check whether --with-magic was given. @@ -27224,7 +27173,11 @@ $as_echo_n "checking if SSL library is wanted... " >&6; } wanted=1; if test -z "$with_ssl" ; then wanted=0; - with_ssl="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_ssl="no"; + else + with_ssl="${CROSS_ENVIRONMENT}/usr"; + fi fi # Check whether --with-ssl was given. @@ -27272,8 +27225,8 @@ $as_echo "#define USE_LIBSSL 1" >>confdefs.h $as_echo "#define HAVE_SSL_TS 1" >>confdefs.h fi - if test x_$PKG_CONFIG != x_no; then - ssl_version=$(pkg-config --modversion openssl) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + ssl_version=$(pkg-config --modversion openssl 2>/dev/null) fi if test -z "$OPENSSL_LINK"; then ULIB_LIBS="-lssl -lcrypto $ULIB_LIBS"; @@ -27303,7 +27256,11 @@ $as_echo_n "checking if PCRE library is wanted... " >&6; } wanted=1; if test -z "$with_pcre" ; then wanted=0; - with_pcre="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_pcre="no"; + else + with_pcre="${CROSS_ENVIRONMENT}/usr"; + fi fi # Check whether --with-pcre was given. @@ -27359,7 +27316,11 @@ $as_echo_n "checking if EXPAT library for XML parsing is wanted... " >&6; } wanted=1; if test -z "$with_expat" ; then wanted=0; - with_expat="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_expat="no"; + else + with_expat="${CROSS_ENVIRONMENT}/usr"; + fi fi # Check whether --with-expat was given. @@ -27415,6 +27376,15 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libuuid library is wanted" >&5 $as_echo_n "checking if libuuid library is wanted... " >&6; } + wanted=1; + if test -z "$with_libuuid" ; then + wanted=0; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_libuuid="no"; + else + with_libuuid="${CROSS_ENVIRONMENT}/usr"; + fi + fi # Check whether --with-libuuid was given. if test "${with_libuuid+set}" = set; then : @@ -27445,8 +27415,8 @@ $as_echo "$msg" >&6; } $as_echo "#define USE_LIBUUID 1" >>confdefs.h - if test x_$PKG_CONFIG != x_no; then - libuuid_version=$(pkg-config --modversion ext2fs) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + libuuid_version=$(pkg-config --modversion ext2fs 2>/dev/null) fi if test -z "${libuuid_version}"; then libuuid_version="unknown" @@ -27466,13 +27436,126 @@ $as_echo "no" >&6; } fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if cURL library is wanted" >&5 +$as_echo_n "checking if cURL library is wanted... " >&6; } + wanted=1; + if test -z "$with_curl" ; then + wanted=0; + with_curl="no"; + fi + +# Check whether --with-curl was given. +if test "${with_curl+set}" = set; then : + withval=$with_curl; if test "$withval" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do + curldir="$dir"; + if test -f "$dir/include/curl/curl.h"; then + found_curl="yes"; + break; + fi + done + if test x_$found_curl != x_yes; then + as_fn_error $? "Cannot find cURL library" "$LINENO" 5 + else + echo "${T_MD}libcurl found in $curldir${T_ME}" + USE_LIBCURL=yes + +$as_echo "#define USE_LIBCURL 1" >>confdefs.h + + libcurl_version=$($curldir/bin/curl-config --version 2>/dev/null | sed -e "s/libcurl //g") + if test -z "${libcurl_version}" -a x_$PKG_CONFIG != x_no; then + libcurl_version=$(pkg-config --modversion libcurl 2>/dev/null) + fi + if test -z "${libcurl_version}"; then + libcurl_version="unknown" + fi + libcurl_linking=$($curldir/bin/curl-config --libs 2>/dev/null) + if test -z "${libcurl_linking}"; then + libcurl_linking="-lcurl" + fi + ULIB_LIBS="$libcurl_linking $ULIB_LIBS"; + if test $curldir != "${CROSS_ENVIRONMENT}/" -a $curldir != "${CROSS_ENVIRONMENT}/usr" -a $curldir != "${CROSS_ENVIRONMENT}/usr/local"; then + CPPFLAGS="$CPPFLAGS -I$curldir/include"; + LDFLAGS="$LDFLAGS -L$curldir/lib -Wl,-R$curldir/lib"; + PRG_LDFLAGS="$PRG_LDFLAGS -L$curldir/lib"; + fi + fi + fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if tdb library is wanted" >&5 +$as_echo_n "checking if tdb library is wanted... " >&6; } + wanted=1; + if test -z "$with_libtdb" ; then + wanted=0; + with_libtdb="no"; + fi + +# Check whether --with-libtdb was given. +if test "${with_libtdb+set}" = set; then : + withval=$with_libtdb; + if test "$withval" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do + libtdbdir="$dir" + if test -f "$dir/include/tdb.h"; then + found_libtdb="yes"; + break; + fi + done + if test x_$found_libtdb != x_yes; then + msg="Cannot find libtdb library"; + if test $wanted = 1; then + as_fn_error $? "$msg" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5 +$as_echo "$msg" >&6; } + fi + else + echo "${T_MD}libtdb found in $libtdbdir${T_ME}" + USE_LIBTDB=yes + +$as_echo "#define USE_LIBTDB 1" >>confdefs.h + + libtdb_version=$(ls $libtdbdir/lib*/libtdb.so.*.* 2>/dev/null | head -n 1 | awk -F'.so.' '{n=2; print $n}' 2>/dev/null) + if test -z "${libtdb_version}"; then + libtdb_version="unknown" + fi + ULIB_LIBS="$ULIB_LIBS -ltdb"; + if test $libtdbdir != "${CROSS_ENVIRONMENT}/" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr/local"; then + CPPFLAGS="$CPPFLAGS -I$libtdbdir/include" + LDFLAGS="$LDFLAGS -L$libtdbdir/lib -Wl,-R$libtdbdir/lib"; + PRG_LDFLAGS="$PRG_LDFLAGS -L$libtdbdir/lib"; + fi + fi + fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if c-ares library for DNS resolution is wanted" >&5 $as_echo_n "checking if c-ares library for DNS resolution is wanted... " >&6; } - if test -n "$with_libares" ; then - wanted=1; - else + wanted=1; + if test -z "$with_libares" ; then wanted=0; - with_libares="${CROSS_ENVIRONMENT}/usr"; + with_libares="no"; fi # Check whether --with-libares was given. @@ -27505,8 +27588,8 @@ $as_echo "$msg" >&6; } $as_echo "#define USE_C_ARES 1" >>confdefs.h - if test x_$PKG_CONFIG != x_no; then - cares_version=$(pkg-config --modversion libcares) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + cares_version=$(pkg-config --modversion libcares 2>/dev/null) fi if test -z "${cares_version}"; then cares_version="unknown" @@ -27528,6 +27611,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if SSH library is wanted" >&5 $as_echo_n "checking if SSH library is wanted... " >&6; } + wanted=1; + if test -z "$with_ssh" ; then + wanted=0; + with_ssh="no"; + fi # Check whether --with-ssh was given. if test "${with_ssh+set}" = set; then : @@ -27571,59 +27659,13 @@ $as_echo "no" >&6; } fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if cURL library is wanted" >&5 -$as_echo_n "checking if cURL library is wanted... " >&6; } - -# Check whether --with-curl was given. -if test "${with_curl+set}" = set; then : - withval=$with_curl; if test "$withval" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do - curldir="$dir"; - if test -f "$dir/include/curl/curl.h"; then - found_curl="yes"; - break; - fi - done - if test x_$found_curl != x_yes; then - as_fn_error $? "Cannot find cURL library" "$LINENO" 5 - else - echo "${T_MD}libcurl found in $curldir${T_ME}" - USE_LIBCURL=yes - -$as_echo "#define USE_LIBCURL 1" >>confdefs.h - - if test x_$PKG_CONFIG != x_no; then - libcurl_version=$(pkg-config --modversion libcurl) - fi - if test -z "${libcurl_version}"; then - libcurl_version=$($curldir/bin/curl-config --version 2>/dev/null | sed -e "s/libcurl //g") - fi - if test -z "${libcurl_version}"; then - libcurl_version="unknown" - fi - libcurl_linking=$($curldir/bin/curl-config --libs 2>/dev/null) - ULIB_LIBS="$libcurl_linking $ULIB_LIBS"; - if test $curldir != "${CROSS_ENVIRONMENT}/" -a $curldir != "${CROSS_ENVIRONMENT}/usr" -a $curldir != "${CROSS_ENVIRONMENT}/usr/local"; then - CPPFLAGS="$CPPFLAGS -I$curldir/include"; - LDFLAGS="$LDFLAGS -L$curldir/lib -Wl,-R$curldir/lib"; - PRG_LDFLAGS="$PRG_LDFLAGS -L$curldir/lib"; - fi - fi - fi - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if LDAP library is wanted" >&5 $as_echo_n "checking if LDAP library is wanted... " >&6; } + wanted=1; + if test -z "$with_ldap" ; then + wanted=0; + with_ldap="no"; + fi # Check whether --with-ldap was given. if test "${with_ldap+set}" = set; then : @@ -27690,6 +27732,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if DBI library is wanted" >&5 $as_echo_n "checking if DBI library is wanted... " >&6; } + wanted=1; + if test -z "$with_dbi" ; then + wanted=0; + with_dbi="no"; + fi # Check whether --with-dbi was given. if test "${with_dbi+set}" = set; then : @@ -27740,6 +27787,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libevent library is wanted" >&5 $as_echo_n "checking if libevent library is wanted... " >&6; } + wanted=1; + if test -z "$with_libevent" ; then + wanted=0; + with_libevent="no"; + fi # Check whether --with-libevent was given. if test "${with_libevent+set}" = set; then : @@ -27785,6 +27837,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libxml2 library is wanted" >&5 $as_echo_n "checking if libxml2 library is wanted... " >&6; } + wanted=1; + if test -z "$with_libxml2" ; then + wanted=0; + with_libxml2="no"; + fi # Check whether --with-libxml2 was given. if test "${with_libxml2+set}" = set; then : @@ -27809,8 +27866,8 @@ $as_echo "yes" >&6; } $as_echo "#define USE_LIBXML2 1" >>confdefs.h - if test x_$PKG_CONFIG != x_no; then - libxml2_version=$(pkg-config --modversion libxml-2.0) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + libxml2_version=$(pkg-config --modversion libxml-2.0 2>/dev/null) fi if test -z "${libxml2_version}"; then libxml2_version="unknown" @@ -27834,6 +27891,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to use page-speed SDK" >&5 $as_echo_n "checking if you want to use page-speed SDK... " >&6; } + wanted=1; + if test -z "$with_page_speed" ; then + wanted=0; + with_page_speed="no"; + fi # Check whether --with-page-speed was given. if test "${with_page_speed+set}" = set; then : @@ -27872,6 +27934,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to use V8 JavaScript Engine" >&5 $as_echo_n "checking if you want to use V8 JavaScript Engine... " >&6; } + wanted=1; + if test -z "$with_v8-javascript" ; then + wanted=0; + with_v8-javascript="no"; + fi # Check whether --with-v8-javascript was given. if test "${with_v8_javascript+set}" = set; then : diff --git a/include/ulib/base/ssl/dgst.h b/include/ulib/base/ssl/dgst.h index 4f345e44..ec85207b 100644 --- a/include/ulib/base/ssl/dgst.h +++ b/include/ulib/base/ssl/dgst.h @@ -21,16 +21,13 @@ #include #if !defined(HAVE_OPENSSL_97) && !defined(HAVE_OPENSSL_98) -#warning "WARNING: I must to disable some function with this version of openssl... be aware" - +# warning "WARNING: I must to disable some function with this version of openssl... be aware" # define HMAC_CTX_init(ctx) # define HMAC_Init_ex(ctx,key,len,md,impl) - # define EVP_MD_CTX_init(ctx) # define EVP_SignInit_ex(a,b,c) # define EVP_MD_CTX_cleanup(ctx) # define EVP_VerifyInit_ex(a,b,c) - # define HMAC_CTX_cleanup(ctx) HMAC_cleanup(ctx) #endif @@ -62,14 +59,20 @@ typedef enum { extern U_EXPORT UHashType u_hashType; /* What type of hash is this? */ extern U_EXPORT EVP_PKEY* restrict u_pkey; /* private key to sign the digest */ -extern U_EXPORT EVP_MD_CTX u_mdctx; /* Context for digest */ extern U_EXPORT const EVP_MD* restrict u_md; /* Digest instance */ extern U_EXPORT unsigned char u_mdValue[U_MAX_HASH_SIZE]; /* Final output */ extern U_EXPORT int u_mdLen; /* Length of digest */ -extern U_EXPORT HMAC_CTX u_hctx; /* Context for HMAC */ -extern U_EXPORT const char* restrict u_hmac_key; /* The loaded key */ -extern U_EXPORT uint32_t u_hmac_keylen; /* The loaded key length */ +extern U_EXPORT const char* restrict u_hmac_key; /* The loaded key */ +extern U_EXPORT uint32_t u_hmac_keylen; /* The loaded key length */ + +#if OPENSSL_VERSION_NUMBER < 0x10100000L +extern U_EXPORT HMAC_CTX u_hctx; /* Context for HMAC */ +extern U_EXPORT EVP_MD_CTX u_mdctx; /* Context for digest */ +#else +extern U_EXPORT HMAC_CTX* u_hctx; /* Context for HMAC */ +extern U_EXPORT EVP_MD_CTX* u_mdctx; /* Context for digest */ +#endif U_EXPORT void u_dgst_algoritm(int alg); U_EXPORT int u_dgst_get_algoritm(const char* restrict alg) __pure; @@ -93,11 +96,19 @@ static inline void u_dgst_hash(unsigned char* restrict data, uint32_t length) if (u_hmac_keylen) { +# if OPENSSL_VERSION_NUMBER < 0x10100000L HMAC_Update(&u_hctx, data, length); +# else + HMAC_Update( u_hctx, data, length); +# endif } else { +# if OPENSSL_VERSION_NUMBER < 0x10100000L (void) EVP_DigestUpdate(&u_mdctx, data, length); +# else + (void) EVP_DigestUpdate( u_mdctx, data, length); +# endif } } @@ -114,8 +125,6 @@ static inline void u_dgst_hash(unsigned char* restrict data, uint32_t length) U_EXPORT int u_dgst_finish(unsigned char* restrict hash, int base64); /* Finish and get hash */ -U_EXPORT void u_dgst_reset(void); /* Reset the hash */ - /** * The EVP signature routines are a high level interface to digital signatures */ @@ -127,14 +136,22 @@ static inline void u_dgst_sign_hash(unsigned char* restrict data, uint32_t lengt { U_INTERNAL_TRACE("u_dgst_sign_hash(%.*s,%u)", U_min(length,128), data, length) +#if OPENSSL_VERSION_NUMBER < 0x10100000L (void) EVP_SignUpdate(&u_mdctx, data, length); +#else + (void) EVP_SignUpdate( u_mdctx, data, length); +#endif } static inline void u_dgst_verify_hash(unsigned char* restrict data, uint32_t length) { U_INTERNAL_TRACE("u_dgst_verify_hash(%.*s,%u)", U_min(length,128), data, length) +#if OPENSSL_VERSION_NUMBER < 0x10100000L (void) EVP_VerifyUpdate(&u_mdctx, data, length); +#else + (void) EVP_VerifyUpdate( u_mdctx, data, length); +#endif } int u_dgst_sign_finish( unsigned char* restrict sig, int base64); /* Finish and get signature */ diff --git a/include/ulib/internal/common.h b/include/ulib/internal/common.h index 37059277..b4d46dc0 100644 --- a/include/ulib/internal/common.h +++ b/include/ulib/internal/common.h @@ -188,7 +188,7 @@ using namespace std; // Init library U_EXPORT void ULib_init(); -#ifdef USE_LIBSSL +#if defined(USE_LIBSSL) && OPENSSL_VERSION_NUMBER < 0x10100000L U_EXPORT void ULib_init_openssl(); #endif diff --git a/include/ulib/internal/config.h.in b/include/ulib/internal/config.h.in index 0cb83f0b..f3ebbf65 100644 --- a/include/ulib/internal/config.h.in +++ b/include/ulib/internal/config.h.in @@ -687,7 +687,7 @@ /* Define if we have support for crc32 intrinsics */ #undef USE_HARDWARE_CRC32 -/* Define if enable libcurL support */ +/* Define if enable libcurl support */ #undef USE_LIBCURL /* Define if enable libdbi support */ diff --git a/include/ulib/json/value.h b/include/ulib/json/value.h index becd4bc5..6c551506 100644 --- a/include/ulib/json/value.h +++ b/include/ulib/json/value.h @@ -1006,8 +1006,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_INTERNAL_ASSERT_EQUALS(json.type_, NULL_VALUE) - json.type_ = STRING_VALUE; U_INTERNAL_DUMP("pval(%p) = %V", pval, pval) @@ -1041,8 +1039,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_INTERNAL_ASSERT_EQUALS(json.type_, NULL_VALUE) - json.type_ = STRING_VALUE; U_INTERNAL_DUMP("pval(%p) = %V", pval, ((UString*)pval)->rep) @@ -1082,8 +1078,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_INTERNAL_ASSERT_EQUALS(json.type_, NULL_VALUE) - json.type_ = ARRAY_VALUE; uvector* pvec = (uvector*)pval; @@ -1108,8 +1102,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_ASSERT(json.isArrayOrObject()) - for (UValue* child = json.children.head; child; child = child->next) { T* pelem; @@ -1137,8 +1129,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_ASSERT(json.isArrayOrObject()) - for (UValue* child = json.children.head; child; child = child->next) { UString elem; @@ -1162,8 +1152,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_INTERNAL_ASSERT_EQUALS(json.type_, NULL_VALUE) - json.type_ = OBJECT_VALUE; uhashmap* pmap = (uhashmap*)pval; @@ -1201,8 +1189,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_ASSERT(json.isObject()) - uhashmap* pmap = (uhashmap*)pval; for (UValue* child = json.children.head; child; child = child->next) @@ -1236,8 +1222,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_ASSERT(json.isObject()) - uhashmap* pmap = (uhashmap*)pval; for (UValue* child = json.children.head; child; child = child->next) @@ -1269,8 +1253,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_INTERNAL_ASSERT_EQUALS(json.type_, NULL_VALUE) - json.type_ = ARRAY_VALUE; stdvector* pvec = (stdvector*)pval; @@ -1293,8 +1275,6 @@ public: U_INTERNAL_DUMP("json.type_ = %d", json.type_) - U_ASSERT(json.isArrayOrObject()) - for (UValue* child = json.children.head; child; child = child->next) { T elem; diff --git a/include/ulib/net/server/usp_macro.h b/include/ulib/net/server/usp_macro.h index 7ce439dc..1490be6e 100644 --- a/include/ulib/net/server/usp_macro.h +++ b/include/ulib/net/server/usp_macro.h @@ -30,8 +30,7 @@ #define USP_JSON_stringify(json,class_name,obj) ((json).toJSON(UJsonTypeHandler(obj)), USP_JSON_PUTS(json)) -#define USP_JSON_OBJ_stringify(class_name,obj) {UValue _jtmp(OBJECT_VALUE); _jtmp.toJSON(UJsonTypeHandler(obj)); USP_JSON_PUTS(_jtmp);} -#define USP_JSON_ARRAY_stringify(class_name,obj) {UValue _jtmp( ARRAY_VALUE); _jtmp.toJSON(UJsonTypeHandler(obj)); USP_JSON_PUTS(_jtmp);} +#define USP_JSON_OBJ_stringify(class_name,obj) {UValue _jtmp; _jtmp.toJSON(UJsonTypeHandler(obj)); USP_JSON_PUTS(_jtmp);} #define USP_XML_PUTS(string) \ ((void)UClientImage_Base::_encoded->reserve((string).size() * 4), \ diff --git a/include/ulib/ssl/certificate.h b/include/ulib/ssl/certificate.h index 7de03c4a..aa83401a 100644 --- a/include/ulib/ssl/certificate.h +++ b/include/ulib/ssl/certificate.h @@ -19,6 +19,11 @@ #include +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +# define X509_get_notBefore X509_getm_notBefore +# define X509_get_notAfter X509_getm_notAfter +#endif + template class UVector; template class UHashMap; @@ -252,49 +257,6 @@ public: long hashCode() { return hashCode(x509); } - /** - * Returns the signature of this certificate - */ - - static UString getSignature(X509* a) - { - U_TRACE(0, "UCertificate::getSignature(%p)", a) - - U_INTERNAL_ASSERT_POINTER(a) - - UString signature( (const char*) a->signature->data, - a->signature->length ); - - U_RETURN_STRING(signature); - } - - UString getSignature() const { return getSignature(x509); } - - /** - * Returns signatureAlgorithm of this certificate - */ - - static UString getSignatureAlgorithm(X509* a) - { - U_TRACE(0, "UCertificate::getSignatureAlgorithm(%p)", a) - - U_INTERNAL_ASSERT_POINTER(a) - - UString signature_algorithm( OBJ_nid2sn( OBJ_obj2nid(a->sig_alg->algorithm) ) ); - - U_RETURN_STRING(signature_algorithm); - } - - UString getSignatureAlgorithm() const { return getSignatureAlgorithm(x509); } - - /** - * Returns the part of this certificate that is signed - */ - - static UString getSignable(X509* x509); - - UString getSignable() const { return getSignable(x509); } - /** * Returns publicKey of this certificate */ @@ -443,13 +405,6 @@ public: UString getExponent() const; - /** - * Gets X509v3 extensions as array of X509Ext objects - */ - - int getExtensions(UHashMap& table) const; - - /** * parse cert's \c authorityInfoAccess extension and find all the * instances of the \c id-ad-caIssuers access method which can be: diff --git a/include/ulib/ssl/crl.h b/include/ulib/ssl/crl.h index 1472e5ea..b45d31e0 100644 --- a/include/ulib/ssl/crl.h +++ b/include/ulib/ssl/crl.h @@ -20,6 +20,11 @@ #include #include +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +# define X509_CRL_get_lastUpdate X509_CRL_get0_lastUpdate +# define X509_CRL_get_nextUpdate X509_CRL_get0_nextUpdate +#endif + class UCertificate; /** @@ -154,22 +159,6 @@ public: U_RETURN(version); } - /** - * Returns the signature of this CRL - */ - - UString getSignature() const - { - U_TRACE_NO_PARAM(0, "UCrl::getSignature()") - - U_INTERNAL_ASSERT_POINTER(crl) - - UString signature( (const char*) crl->signature->data, - crl->signature->length ); - - U_RETURN_STRING(signature); - } - /** * Returns the last update of this CRL */ @@ -180,7 +169,7 @@ public: U_INTERNAL_ASSERT_POINTER(crl) - ASN1_UTCTIME* utctime = X509_CRL_get_lastUpdate(crl); + const ASN1_UTCTIME* utctime = X509_CRL_get_lastUpdate(crl); U_RETURN((const char*)utctime->data); } @@ -198,7 +187,7 @@ public: U_INTERNAL_ASSERT_POINTER(crl) - ASN1_UTCTIME* utctime = X509_CRL_get_nextUpdate(crl); + const ASN1_UTCTIME* utctime = X509_CRL_get_nextUpdate(crl); U_RETURN((const char*)utctime->data); } diff --git a/include/ulib/ssl/net/ssl_session.h b/include/ulib/ssl/net/ssl_session.h index 114c4cd4..292296c4 100644 --- a/include/ulib/ssl/net/ssl_session.h +++ b/include/ulib/ssl/net/ssl_session.h @@ -53,8 +53,9 @@ public: private: static SSL_SESSION* sess; - static int newSession(SSL* ssl, SSL_SESSION* sess); - static void removeSession(SSL_CTX* ctx, SSL_SESSION* sess); + static int newSession(SSL* ssl, SSL_SESSION* sess); + static void removeSession(SSL_CTX* ctx, SSL_SESSION* sess); + static SSL_SESSION* getSession(SSL* ssl, unsigned char* id, int len, int* copy); U_DISALLOW_COPY_AND_ASSIGN(USSLSession) diff --git a/include/ulib/ssl/pkcs10.h b/include/ulib/ssl/pkcs10.h index 5dee2c21..b706992e 100644 --- a/include/ulib/ssl/pkcs10.h +++ b/include/ulib/ssl/pkcs10.h @@ -115,45 +115,6 @@ public: U_RETURN(version); } - /** - * Returns the signature of this certificateRequest - */ - - UString getSignature() const - { - U_TRACE_NO_PARAM(0, "UPKCS10::getSignature()") - - U_INTERNAL_ASSERT_POINTER(request) - - UString signature( (const char*) request->signature->data, - request->signature->length ); - - U_RETURN_STRING(signature); - } - - /** - * Returns signatureAlgorithm of this certificateRequest - */ - - UString getSignatureAlgorithm() const - { - U_TRACE_NO_PARAM(0, "UPKCS10::getSignatureAlgorithm()") - - U_INTERNAL_ASSERT_POINTER(request) - - UString signature_algorithm( OBJ_nid2sn( OBJ_obj2nid(request->sig_alg->algorithm) ) ); - - U_RETURN_STRING(signature_algorithm); - } - - /** - * Returns the part of this certificateRequest that is signed - */ - - static UString getSignable(X509_REQ* request); - - UString getSignable() const { return getSignable(request); } - /** * Returns publicKey of this certificateRequest */ diff --git a/include/ulib/utility/uhttp.h b/include/ulib/utility/uhttp.h index b0c71814..1000554f 100644 --- a/include/ulib/utility/uhttp.h +++ b/include/ulib/utility/uhttp.h @@ -239,32 +239,7 @@ public: *upload_dir = dir; } - static void setHostname(const char* ptr, uint32_t len) - { - U_TRACE(0, "UHTTP::setHostname(%.*S,%u)", len, ptr, len) - - // The difference between HTTP_HOST and U_HTTP_VHOST is that HTTP_HOST can include the «:PORT» text, and U_HTTP_VHOST only the name - - U_http_host_len = - U_http_host_vlen = len; - U_http_info.host = ptr; - - U_INTERNAL_DUMP("U_http_host_len = %u U_HTTP_HOST = %.*S", U_http_host_len, U_HTTP_HOST_TO_TRACE) - - // hostname[:port] - - for (const char* endptr = ptr+len; ptr < endptr; ++ptr) - { - if (*ptr == ':') - { - U_http_host_vlen = ptr-U_http_info.host; - - break; - } - } - - U_INTERNAL_DUMP("U_http_host_vlen = %u U_HTTP_VHOST = %.*S", U_http_host_vlen, U_HTTP_VHOST_TO_TRACE) - } + static void setHostname(const char* ptr, uint32_t len); static const char* getStatusDescription(uint32_t* plen = 0); @@ -1065,6 +1040,7 @@ private: static void checkPath() U_NO_EXPORT; static bool callService() U_NO_EXPORT; + static void checkIPClient() U_NO_EXPORT; static bool runDynamicPage() U_NO_EXPORT; static bool readBodyRequest() U_NO_EXPORT; static bool processFileCache() U_NO_EXPORT; @@ -1091,6 +1067,23 @@ private: static bool readDataChunked(USocket* sk, UString* pbuffer, UString& body) U_NO_EXPORT; static void setResponseForRange(uint32_t start, uint32_t end, uint32_t header) U_NO_EXPORT; + static inline void setUpgrade(const char* ptr) U_NO_EXPORT; + static inline void setIfModSince(const char* ptr) U_NO_EXPORT; + static inline void setConnection(const char* ptr) U_NO_EXPORT; + static inline void setAcceptEncoding(const char* ptr) U_NO_EXPORT; + static inline void setContentLength(const char* ptr1, const char* ptr2) U_NO_EXPORT; + + static inline void setRange(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setCookie(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setUserAgent(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setAccept(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setReferer(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setXRealIP(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setContentType(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setAcceptLanguage(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setXForwardedFor(const char* ptr, uint32_t len) U_NO_EXPORT; + static inline void setXHttpForwardedFor(const char* ptr, uint32_t len) U_NO_EXPORT; + U_DISALLOW_COPY_AND_ASSIGN(UHTTP) friend class USSIPlugIn; diff --git a/m4/ac_check_package.m4 b/m4/ac_check_package.m4 index debc9309..9342909f 100644 --- a/m4/ac_check_package.m4 +++ b/m4/ac_check_package.m4 @@ -7,7 +7,11 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ wanted=1; if test -z "$with_libz" ; then wanted=0; - with_libz="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" ; then + with_libz="no"; + else + with_libz="${CROSS_ENVIRONMENT}/usr"; + fi fi AC_ARG_WITH(libz, [ --with-libz use system LIBZ library - [[will check /usr /usr/local]] [[default=use if present]]], [ if test "$withval" = "no"; then @@ -47,66 +51,21 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if you want to enable build of ZIP support) - AC_ARG_ENABLE(zip, [ --enable-zip enable build of ZIP support - require libz [[default: use if present libz]]]) - if test "$enable_zip" != "no" -a x_$found_libz = x_yes; then - enable_zip="yes" + if test x_$found_libz = x_yes; then + if test -z "$enable_zip" -o x_$enable_zip != x_no; then + enable_zip="yes" + fi else enable_zip="no" fi + AC_ARG_ENABLE(zip, [ --enable-zip enable build of ZIP support - require libz [[default: use if present libz]]]) AC_MSG_RESULT([$enable_zip]) - AC_MSG_CHECKING(if tdb library is wanted) - wanted=1; - if test -z "$with_libtdb" ; then - wanted=0; - if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then - with_libtdb="no"; - else - with_libtdb="${CROSS_ENVIRONMENT}/usr"; - fi - fi - AC_ARG_WITH(libtdb, [ --with-libtdb use system tdb library - [[will check /usr /usr/local]] [[default=use if present]]], [ - if test "$withval" = "no"; then - AC_MSG_RESULT(no) - else - AC_MSG_RESULT(yes) - for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do - libtdbdir="$dir" - if test -f "$dir/include/tdb.h"; then - found_libtdb="yes"; - break; - fi - done - if test x_$found_libtdb != x_yes; then - msg="Cannot find libtdb library"; - if test $wanted = 1; then - AC_MSG_ERROR($msg) - else - AC_MSG_RESULT($msg) - fi - else - echo "${T_MD}libtdb found in $libtdbdir${T_ME}" - USE_LIBTDB=yes - AC_DEFINE(USE_LIBTDB, 1, [Define if enable libtdb support]) - libtdb_version=$(ls $libtdbdir/lib*/libtdb.so.*.* 2>/dev/null | head -n 1 | awk -F'.so.' '{n=2; print $n}' 2>/dev/null) - if test -z "${libtdb_version}"; then - libtdb_version="unknown" - fi - ULIB_LIBS="$ULIB_LIBS -ltdb"; - if test $libtdbdir != "${CROSS_ENVIRONMENT}/" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr/local"; then - CPPFLAGS="$CPPFLAGS -I$libtdbdir/include" - LDFLAGS="$LDFLAGS -L$libtdbdir/lib -Wl,-R$libtdbdir/lib"; - PRG_LDFLAGS="$PRG_LDFLAGS -L$libtdbdir/lib"; - fi - fi - fi - ], [AC_MSG_RESULT(no)]) - AC_MSG_CHECKING(if zopfli library is wanted) wanted=1; if test -z "$with_libzopfli" ; then wanted=0; - if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then with_libzopfli="no"; else with_libzopfli="${CROSS_ENVIRONMENT}/usr"; @@ -153,7 +112,11 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ wanted=1; if test -z "$with_magic" ; then wanted=0; - with_magic="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_magic="no"; + else + with_magic="${CROSS_ENVIRONMENT}/usr"; + fi fi AC_ARG_WITH(magic, [ --with-magic use system libmagic library - [[will check /usr /usr/local]] [[default=use if present]]], [if test "$withval" = "no"; then @@ -196,7 +159,11 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ wanted=1; if test -z "$with_ssl" ; then wanted=0; - with_ssl="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_ssl="no"; + else + with_ssl="${CROSS_ENVIRONMENT}/usr"; + fi fi AC_ARG_WITH(ssl, [ --with-ssl use system SSL library - [[will check /usr /usr/local]] [[default=use if present]]], [if test "$withval" = "no"; then @@ -235,8 +202,8 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ HAVE_SSL_TS="yes"; AC_DEFINE(HAVE_SSL_TS, 1, [Define if we have time stamp support in openssl]) fi - if test x_$PKG_CONFIG != x_no; then - ssl_version=$(pkg-config --modversion openssl) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + ssl_version=$(pkg-config --modversion openssl 2>/dev/null) fi if test -z "$OPENSSL_LINK"; then ULIB_LIBS="-lssl -lcrypto $ULIB_LIBS"; @@ -260,7 +227,11 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ wanted=1; if test -z "$with_pcre" ; then wanted=0; - with_pcre="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_pcre="no"; + else + with_pcre="${CROSS_ENVIRONMENT}/usr"; + fi fi AC_ARG_WITH(pcre, [ --with-pcre use system PCRE library - [[will check /usr /usr/local]] [[default=use if present]]], [if test "$withval" = "no"; then @@ -303,7 +274,11 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ wanted=1; if test -z "$with_expat" ; then wanted=0; - with_expat="${CROSS_ENVIRONMENT}/usr"; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_expat="no"; + else + with_expat="${CROSS_ENVIRONMENT}/usr"; + fi fi AC_ARG_WITH(expat, [ --with-expat use system EXPAT library - [[will check /usr /usr/local]] [[default=use if present]]], [if test "$withval" = "no"; then @@ -346,7 +321,16 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if libuuid library is wanted) - AC_ARG_WITH(libuuid, [ --with-libuuid use system libuuid library - [[will check /usr /usr/local]]], + wanted=1; + if test -z "$with_libuuid" ; then + wanted=0; + if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then + with_libuuid="no"; + else + with_libuuid="${CROSS_ENVIRONMENT}/usr"; + fi + fi + AC_ARG_WITH(libuuid, [ --with-libuuid use system libuuid library - [[will check /usr /usr/local]] [[default=use if present]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) else @@ -369,8 +353,8 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ echo "${T_MD}libuuid found in $libuuiddir${T_ME}" USE_LIBUUID=yes AC_DEFINE(USE_LIBUUID, 1, [Define if enable libuuid support]) - if test x_$PKG_CONFIG != x_no; then - libuuid_version=$(pkg-config --modversion ext2fs) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + libuuid_version=$(pkg-config --modversion ext2fs 2>/dev/null) fi if test -z "${libuuid_version}"; then libuuid_version="unknown" @@ -385,12 +369,99 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ fi ], [AC_MSG_RESULT(no)]) - AC_MSG_CHECKING(if c-ares library for DNS resolution is wanted) - if test -n "$with_libares" ; then - wanted=1; - else + AC_MSG_CHECKING(if cURL library is wanted) + wanted=1; + if test -z "$with_curl" ; then wanted=0; - with_libares="${CROSS_ENVIRONMENT}/usr"; + with_curl="no"; + fi + AC_ARG_WITH(curl, [ --with-curl use system cURL library - [[will check /usr /usr/local]]], + [if test "$withval" = "no"; then + AC_MSG_RESULT(no) + else + AC_MSG_RESULT(yes) + for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do + curldir="$dir"; + if test -f "$dir/include/curl/curl.h"; then + found_curl="yes"; + break; + fi + done + if test x_$found_curl != x_yes; then + AC_MSG_ERROR(Cannot find cURL library) + else + echo "${T_MD}libcurl found in $curldir${T_ME}" + USE_LIBCURL=yes + AC_DEFINE(USE_LIBCURL, 1, [Define if enable libcurl support]) + libcurl_version=$($curldir/bin/curl-config --version 2>/dev/null | sed -e "s/libcurl //g") + if test -z "${libcurl_version}" -a x_$PKG_CONFIG != x_no; then + libcurl_version=$(pkg-config --modversion libcurl 2>/dev/null) + fi + if test -z "${libcurl_version}"; then + libcurl_version="unknown" + fi + libcurl_linking=$($curldir/bin/curl-config --libs 2>/dev/null) + if test -z "${libcurl_linking}"; then + libcurl_linking="-lcurl" + fi + ULIB_LIBS="$libcurl_linking $ULIB_LIBS"; + if test $curldir != "${CROSS_ENVIRONMENT}/" -a $curldir != "${CROSS_ENVIRONMENT}/usr" -a $curldir != "${CROSS_ENVIRONMENT}/usr/local"; then + CPPFLAGS="$CPPFLAGS -I$curldir/include"; + LDFLAGS="$LDFLAGS -L$curldir/lib -Wl,-R$curldir/lib"; + PRG_LDFLAGS="$PRG_LDFLAGS -L$curldir/lib"; + fi + fi + fi + ], [AC_MSG_RESULT(no)]) + + AC_MSG_CHECKING(if tdb library is wanted) + wanted=1; + if test -z "$with_libtdb" ; then + wanted=0; + with_libtdb="no"; + fi + AC_ARG_WITH(libtdb, [ --with-libtdb use system tdb library - [[will check /usr /usr/local]]], [ + if test "$withval" = "no"; then + AC_MSG_RESULT(no) + else + AC_MSG_RESULT(yes) + for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do + libtdbdir="$dir" + if test -f "$dir/include/tdb.h"; then + found_libtdb="yes"; + break; + fi + done + if test x_$found_libtdb != x_yes; then + msg="Cannot find libtdb library"; + if test $wanted = 1; then + AC_MSG_ERROR($msg) + else + AC_MSG_RESULT($msg) + fi + else + echo "${T_MD}libtdb found in $libtdbdir${T_ME}" + USE_LIBTDB=yes + AC_DEFINE(USE_LIBTDB, 1, [Define if enable libtdb support]) + libtdb_version=$(ls $libtdbdir/lib*/libtdb.so.*.* 2>/dev/null | head -n 1 | awk -F'.so.' '{n=2; print $n}' 2>/dev/null) + if test -z "${libtdb_version}"; then + libtdb_version="unknown" + fi + ULIB_LIBS="$ULIB_LIBS -ltdb"; + if test $libtdbdir != "${CROSS_ENVIRONMENT}/" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr" -a $libtdbdir != "${CROSS_ENVIRONMENT}/usr/local"; then + CPPFLAGS="$CPPFLAGS -I$libtdbdir/include" + LDFLAGS="$LDFLAGS -L$libtdbdir/lib -Wl,-R$libtdbdir/lib"; + PRG_LDFLAGS="$PRG_LDFLAGS -L$libtdbdir/lib"; + fi + fi + fi + ], [AC_MSG_RESULT(no)]) + + AC_MSG_CHECKING(if c-ares library for DNS resolution is wanted) + wanted=1; + if test -z "$with_libares" ; then + wanted=0; + with_libares="no"; fi AC_ARG_WITH(libares, [ --with-libares use system c-ares library - [[will check /usr /usr/local]]], [ if test "$withval" = "no"; then @@ -415,8 +486,8 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ echo "${T_MD}libcares found in $caresdir${T_ME}" USE_C_ARES=yes AC_DEFINE(USE_C_ARES, 1, [Define if enable c-ares support]) - if test x_$PKG_CONFIG != x_no; then - cares_version=$(pkg-config --modversion libcares) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + cares_version=$(pkg-config --modversion libcares 2>/dev/null) fi if test -z "${cares_version}"; then cares_version="unknown" @@ -432,6 +503,11 @@ AC_DEFUN([AC_CHECK_PACKAGE],[ ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if SSH library is wanted) + wanted=1; + if test -z "$with_ssh" ; then + wanted=0; + with_ssh="no"; + fi AC_ARG_WITH(ssh, [ --with-ssh use system SSH library - [[will check /usr /usr/local]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) @@ -465,46 +541,12 @@ dnl libssh_version=$(grep LIBSFTP_VERSION $sshdir/include/libssh/sftp.h | cut - fi ], [AC_MSG_RESULT(no)]) - AC_MSG_CHECKING(if cURL library is wanted) - AC_ARG_WITH(curl, [ --with-curl use system cURL library - [[will check /usr /usr/local]]], - [if test "$withval" = "no"; then - AC_MSG_RESULT(no) - else - AC_MSG_RESULT(yes) - for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do - curldir="$dir"; - if test -f "$dir/include/curl/curl.h"; then - found_curl="yes"; - break; - fi - done - if test x_$found_curl != x_yes; then - AC_MSG_ERROR(Cannot find cURL library) - else - echo "${T_MD}libcurl found in $curldir${T_ME}" - USE_LIBCURL=yes - AC_DEFINE(USE_LIBCURL, 1, [Define if enable libcurL support]) - if test x_$PKG_CONFIG != x_no; then - libcurl_version=$(pkg-config --modversion libcurl) - fi - if test -z "${libcurl_version}"; then - libcurl_version=$($curldir/bin/curl-config --version 2>/dev/null | sed -e "s/libcurl //g") - fi - if test -z "${libcurl_version}"; then - libcurl_version="unknown" - fi - libcurl_linking=$($curldir/bin/curl-config --libs 2>/dev/null) - ULIB_LIBS="$libcurl_linking $ULIB_LIBS"; - if test $curldir != "${CROSS_ENVIRONMENT}/" -a $curldir != "${CROSS_ENVIRONMENT}/usr" -a $curldir != "${CROSS_ENVIRONMENT}/usr/local"; then - CPPFLAGS="$CPPFLAGS -I$curldir/include"; - LDFLAGS="$LDFLAGS -L$curldir/lib -Wl,-R$curldir/lib"; - PRG_LDFLAGS="$PRG_LDFLAGS -L$curldir/lib"; - fi - fi - fi - ], [AC_MSG_RESULT(no)]) - AC_MSG_CHECKING(if LDAP library is wanted) + wanted=1; + if test -z "$with_ldap" ; then + wanted=0; + with_ldap="no"; + fi AC_ARG_WITH(ldap, [ --with-ldap use system openLDAP library - [[will check /usr /usr/local]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) @@ -561,6 +603,11 @@ dnl ldap_version=$(ldapsearch -VV 2>&1 | tail -n1 | cut -d':' -f2 | cut -d')' - ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if DBI library is wanted) + wanted=1; + if test -z "$with_dbi" ; then + wanted=0; + with_dbi="no"; + fi AC_ARG_WITH(dbi, [ --with-dbi use system DBI library - [[will check /usr /usr/local]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) @@ -599,6 +646,11 @@ dnl ldap_version=$(ldapsearch -VV 2>&1 | tail -n1 | cut -d':' -f2 | cut -d')' - ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if libevent library is wanted) + wanted=1; + if test -z "$with_libevent" ; then + wanted=0; + with_libevent="no"; + fi AC_ARG_WITH(libevent, [ --with-libevent use system libevent library - [[will check /usr /usr/local]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) @@ -632,6 +684,11 @@ dnl ldap_version=$(ldapsearch -VV 2>&1 | tail -n1 | cut -d':' -f2 | cut -d')' - ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if libxml2 library is wanted) + wanted=1; + if test -z "$with_libxml2" ; then + wanted=0; + with_libxml2="no"; + fi AC_ARG_WITH(libxml2, [ --with-libxml2 use system libxml2 library - [[will check /usr /usr/local]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) @@ -650,8 +707,8 @@ dnl ldap_version=$(ldapsearch -VV 2>&1 | tail -n1 | cut -d':' -f2 | cut -d')' - echo "${T_MD}libxml2 found in $libxml2dir${T_ME}" USE_LIBXML2=yes AC_DEFINE(USE_LIBXML2, 1, [Define if enable libxml2 support]) - if test x_$PKG_CONFIG != x_no; then - libxml2_version=$(pkg-config --modversion libxml-2.0) + if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then + libxml2_version=$(pkg-config --modversion libxml-2.0 2>/dev/null) fi if test -z "${libxml2_version}"; then libxml2_version="unknown" @@ -669,6 +726,11 @@ dnl ldap_version=$(ldapsearch -VV 2>&1 | tail -n1 | cut -d':' -f2 | cut -d')' - ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if you want to use page-speed SDK) + wanted=1; + if test -z "$with_page_speed" ; then + wanted=0; + with_page_speed="no"; + fi AC_ARG_WITH(page-speed, [ --with-page-speed use google page-speed SDK - [[will check /usr /usr/local]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) @@ -695,6 +757,11 @@ dnl ldap_version=$(ldapsearch -VV 2>&1 | tail -n1 | cut -d':' -f2 | cut -d')' - ], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING(if you want to use V8 JavaScript Engine) + wanted=1; + if test -z "$with_v8-javascript" ; then + wanted=0; + with_v8-javascript="no"; + fi AC_ARG_WITH(v8-javascript, [ --with-v8-javascript use V8 JavaScript Engine - [[will check /usr /usr/local]]], [if test "$withval" = "no"; then AC_MSG_RESULT(no) diff --git a/openwrt/package/nodog/x86_64/Makefile b/openwrt/package/nodog/x86_64/Makefile index d421a00c..ab9724c0 100644 --- a/openwrt/package/nodog/x86_64/Makefile +++ b/openwrt/package/nodog/x86_64/Makefile @@ -43,7 +43,7 @@ define Package/nodog/conffiles endef NODOG_OPTIONS:= --disable-examples \ - --with-ssl --with-libz \ + --with-ssl --with-libz --with-libtdb \ --without-expat --without-magic --without-pcre \ --disable-static --disable-new-ldflags --disable-zip --disable-LFS \ --enable-log --enable-captive-portal --enable-static-server-plugin="nocat http" \ diff --git a/src/ulib/base/miniz/miniz.c b/src/ulib/base/miniz/miniz.c index e6ead7b9..1100d8b3 100644 --- a/src/ulib/base/miniz/miniz.c +++ b/src/ulib/base/miniz/miniz.c @@ -42,7 +42,7 @@ extern "C" { // ------------------- zlib-style API's -mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) +__pure mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) { mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552; @@ -92,7 +92,7 @@ mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) } #else // Faster, but larger CPU cache footprint. -mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) +__pure mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) { static const mz_uint32 s_crc_table[256] = { @@ -557,7 +557,7 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char return mz_inflateEnd(&stream); } -const char *mz_error(int err) +__pure const char *mz_error(int err) { static struct { @@ -2565,12 +2565,12 @@ tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_fun return TDEFL_STATUS_OKAY; } -tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) +__pure tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) { return d->m_prev_return_status; } -mz_uint32 tdefl_get_adler32(tdefl_compressor *d) +__pure mz_uint32 tdefl_get_adler32(tdefl_compressor *d) { return d->m_adler32; } diff --git a/src/ulib/base/ssl/cdes3.c b/src/ulib/base/ssl/cdes3.c index 730083ad..86e6a5e8 100644 --- a/src/ulib/base/ssl/cdes3.c +++ b/src/ulib/base/ssl/cdes3.c @@ -26,6 +26,14 @@ #define U_DECRYPT 0 #define U_STR_MAGIC "Salted__" +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +# define des_cblock DES_cblock +# define des_key_schedule DES_key_schedule +# define des_string_to_key DES_string_to_key +# define RAND_pseudo_bytes RAND_bytes +# define des_set_odd_parity DES_set_odd_parity +#endif + static const char* password; static const EVP_MD* md; @@ -48,12 +56,21 @@ void u_des_init(void) u__memcpy(&inp_ivec, &key, sizeof(inp_ivec), __PRETTY_FUNCTION__); u__memcpy(&out_ivec, &key, sizeof(out_ivec), __PRETTY_FUNCTION__); +#if OPENSSL_VERSION_NUMBER < 0x10100000L (void) des_set_key(&inp_ivec, inp1_sched); (void) des_set_key(&inp_ivec, inp2_sched); (void) des_set_key(&inp_ivec, inp3_sched); (void) des_set_key(&out_ivec, out1_sched); (void) des_set_key(&out_ivec, out2_sched); (void) des_set_key(&out_ivec, out3_sched); +#else + (void) DES_set_key(&inp_ivec, &inp1_sched); + (void) DES_set_key(&inp_ivec, &inp2_sched); + (void) DES_set_key(&inp_ivec, &inp3_sched); + (void) DES_set_key(&out_ivec, &out1_sched); + (void) DES_set_key(&out_ivec, &out2_sched); + (void) DES_set_key(&out_ivec, &out3_sched); +#endif } void u_des3_init(void) @@ -128,7 +145,11 @@ long u_des_encode(const unsigned char* restrict inp, long len, unsigned char* re * The extra state information to record how much of the 64bit block we have used is contained in inp_num */ - des_ede3_cfb64_encrypt(inp, out, len, out1_sched, out2_sched, out3_sched, &out_ivec, &inp_num, DES_ENCRYPT); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + des_ede3_cfb64_encrypt(inp, out, len, out1_sched, out2_sched, out3_sched, &out_ivec, &inp_num, DES_ENCRYPT); +#else + DES_ede3_cfb64_encrypt(inp, out, len, &out1_sched, &out2_sched, &out3_sched, &out_ivec, &inp_num, DES_ENCRYPT); +#endif U_INTERNAL_PRINT("inp_num = %d", inp_num) @@ -181,7 +202,11 @@ long u_des_decode(const unsigned char* restrict inp, long len, unsigned char* re * The extra state information to record how much of the 64bit block we have used is contained in out_num */ - des_ede3_cfb64_encrypt(inp, out, len, inp1_sched, inp2_sched, inp3_sched, &inp_ivec, &out_num, DES_DECRYPT); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + des_ede3_cfb64_encrypt(inp, out, len, inp1_sched, inp2_sched, inp3_sched, &inp_ivec, &out_num, DES_DECRYPT); +#else + DES_ede3_cfb64_encrypt(inp, out, len, &inp1_sched, &inp2_sched, &inp3_sched, &inp_ivec, &out_num, DES_DECRYPT); +#endif U_INTERNAL_PRINT("out_num = %d", out_num) diff --git a/src/ulib/base/ssl/dgst.c b/src/ulib/base/ssl/dgst.c index 38ef42a7..6a0491aa 100644 --- a/src/ulib/base/ssl/dgst.c +++ b/src/ulib/base/ssl/dgst.c @@ -16,16 +16,28 @@ #include #include +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +# ifndef OPENSSL_NO_SHA0 +# define OPENSSL_NO_SHA0 +# endif +#endif + UHashType u_hashType; /* What type of hash is this? */ EVP_PKEY* restrict u_pkey; /* private key to sign the digest */ -EVP_MD_CTX u_mdctx; /* Context for digest */ const EVP_MD* restrict u_md; /* Digest instance */ unsigned char u_mdValue[U_MAX_HASH_SIZE]; /* Final output */ int u_mdLen; /* Length of digest */ -HMAC_CTX u_hctx; /* Context for HMAC */ -const char* restrict u_hmac_key; /* The loaded key */ -uint32_t u_hmac_keylen; /* The loaded key length */ +const char* restrict u_hmac_key; /* The loaded key */ +uint32_t u_hmac_keylen; /* The loaded key length */ + +#if OPENSSL_VERSION_NUMBER < 0x10100000L +HMAC_CTX u_hctx; /* Context for HMAC */ +EVP_MD_CTX u_mdctx; /* Context for digest */ +#else +HMAC_CTX* u_hctx; /* Context for HMAC */ +EVP_MD_CTX* u_mdctx; /* Context for digest */ +#endif __pure int u_dgst_get_algoritm(const char* restrict alg) { @@ -113,37 +125,30 @@ void u_dgst_init(int alg, const char* restrict _key, uint32_t keylen) u_hmac_key = _key; u_hmac_keylen = keylen; +# if OPENSSL_VERSION_NUMBER < 0x10100000L HMAC_CTX_cleanup(&u_hctx); HMAC_CTX_init(&u_hctx); + HMAC_Init_ex(&u_hctx, _key, keylen, u_md, 0); +# else + if (u_hctx) (void) HMAC_CTX_reset(u_hctx); + else u_hctx = HMAC_CTX_new(); + + HMAC_Init_ex(u_hctx, _key, keylen, u_md, 0); +# endif } else { - EVP_MD_CTX_cleanup(&u_mdctx); +# if OPENSSL_VERSION_NUMBER < 0x10100000L + EVP_MD_CTX_cleanup(&u_mdctx); + (void) EVP_DigestInit(&u_mdctx, u_md); - } -} +# else + if (u_mdctx) EVP_MD_CTX_reset(u_mdctx); + else u_mdctx = EVP_MD_CTX_new(); -void u_dgst_reset(void) /* Reset the hash */ -{ - U_INTERNAL_TRACE("u_dgst_reset()") - - U_INTERNAL_PRINT("alg = %d", u_hashType) - - U_INTERNAL_ASSERT_POINTER(u_md) - - if (u_hmac_keylen) - { - HMAC_CTX_cleanup(&u_hctx); - - HMAC_CTX_init(&u_hctx); - - HMAC_Init_ex(&u_hctx, u_hmac_key, u_hmac_keylen, u_md, 0); - } - else - { - EVP_MD_CTX_cleanup(&u_mdctx); - (void) EVP_DigestInit(&u_mdctx, u_md); + (void) EVP_DigestInit_ex(u_mdctx, u_md, 0); +# endif } } @@ -156,7 +161,7 @@ static int u_finish(unsigned char* restrict ptr, int base64) if (base64 == 0) return u_hexdump_encode(u_mdValue, u_mdLen, ptr); if (base64 == 1) return u_base64_encode( u_mdValue, u_mdLen, ptr); - if (base64 == -1) u__memcpy(ptr, u_mdValue, u_mdLen, __PRETTY_FUNCTION__); + if (base64 == -1) u__memcpy(ptr, u_mdValue, u_mdLen, __PRETTY_FUNCTION__); return u_mdLen; } @@ -169,11 +174,19 @@ int u_dgst_finish(unsigned char* restrict hash, int base64) /* Finish and get ha if (u_hmac_keylen) { +# if OPENSSL_VERSION_NUMBER < 0x10100000L HMAC_Final(&u_hctx, u_mdValue, (unsigned int*)&u_mdLen); +# else + HMAC_Final( u_hctx, u_mdValue, (unsigned int*)&u_mdLen); +# endif } else { +# if OPENSSL_VERSION_NUMBER < 0x10100000L (void) EVP_DigestFinal(&u_mdctx, u_mdValue, (unsigned int*)&u_mdLen); +# else + (void) EVP_DigestFinal( u_mdctx, u_mdValue, (unsigned int*)&u_mdLen); +# endif } if (hash) return u_finish(hash, base64); @@ -189,16 +202,17 @@ void u_dgst_sign_init(int alg, ENGINE* impl) u_dgst_algoritm(alg); +#if OPENSSL_VERSION_NUMBER < 0x10100000L EVP_MD_CTX_cleanup(&u_mdctx); - EVP_MD_CTX_init(&u_mdctx); - /** - * sets up signing context ctx to use digest type from ENGINE impl. - * u_mdctx must be initialized with EVP_MD_CTX_init() before calling this function - */ - EVP_SignInit_ex(&u_mdctx, u_md, impl); +#else + if (u_mdctx) EVP_MD_CTX_reset(u_mdctx); + else u_mdctx = EVP_MD_CTX_new(); + + (void) EVP_DigestInit_ex(u_mdctx, u_md, impl); +#endif } void u_dgst_verify_init(int alg, ENGINE* restrict impl) @@ -207,16 +221,17 @@ void u_dgst_verify_init(int alg, ENGINE* restrict impl) u_dgst_algoritm(alg); +#if OPENSSL_VERSION_NUMBER < 0x10100000L EVP_MD_CTX_cleanup(&u_mdctx); - EVP_MD_CTX_init(&u_mdctx); - /** - * sets up signing context ctx to use digest type from ENGINE impl. - * u_mdctx must be initialized with EVP_MD_CTX_init() before calling this function - */ - EVP_VerifyInit_ex(&u_mdctx, u_md, impl); +#else + if (u_mdctx) EVP_MD_CTX_reset(u_mdctx); + else u_mdctx = EVP_MD_CTX_new(); + + (void) EVP_DigestInit_ex(u_mdctx, u_md, impl); +#endif } int u_dgst_sign_finish(unsigned char* restrict sig, int base64) /* Finish and get signature */ @@ -225,7 +240,11 @@ int u_dgst_sign_finish(unsigned char* restrict sig, int base64) /* Finish and ge U_INTERNAL_ASSERT_POINTER(u_pkey) +#if OPENSSL_VERSION_NUMBER < 0x10100000L (void) EVP_SignFinal(&u_mdctx, u_mdValue, (unsigned int*)&u_mdLen, u_pkey); +#else + (void) EVP_SignFinal( u_mdctx, u_mdValue, (unsigned int*)&u_mdLen, u_pkey); +#endif if (sig) return u_finish(sig, base64); @@ -238,5 +257,9 @@ int u_dgst_verify_finish(unsigned char* restrict sigbuf, uint32_t siglen) U_INTERNAL_ASSERT_POINTER(u_pkey) +#if OPENSSL_VERSION_NUMBER < 0x10100000L return EVP_VerifyFinal(&u_mdctx, sigbuf, siglen, u_pkey); +#else + return EVP_VerifyFinal( u_mdctx, sigbuf, siglen, u_pkey); +#endif } diff --git a/src/ulib/base/xxhash/xxhash.c b/src/ulib/base/xxhash/xxhash.c index c720c181..6521c027 100644 --- a/src/ulib/base/xxhash/xxhash.c +++ b/src/ulib/base/xxhash/xxhash.c @@ -378,8 +378,27 @@ FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH return h32; } +#ifdef __GNUC__ +# define GCC_VERSION_NUM (__GNUC__ * 10000 + \ + __GNUC_MINOR__ * 100 + \ + __GNUC_PATCHLEVEL__) +# if GCC_VERSION_NUM > 29600 && GCC_VERSION_NUM != 30303 /* Test for GCC == 3.3.3 (SuSE Linux) */ +# if defined(LINUX) || defined(__LINUX__) || defined(__linux__) || defined(__linux) +# define U_LINUX +# elif defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) +# define _MSWINDOWS_ +# endif +# if defined(U_LINUX) || defined(_MSWINDOWS_) +# define __pure __attribute__((pure)) +# endif +# else +# define __pure +# endif +#else +# define __pure +#endif /* __GNUC__ */ -XXH_PUBLIC_API unsigned int XXH32 (const void* input, size_t len, unsigned int seed) +XXH_PUBLIC_API __pure unsigned int XXH32 (const void* input, size_t len, unsigned int seed) { #if 0 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ @@ -519,7 +538,7 @@ FORCE_INLINE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH } -XXH_PUBLIC_API unsigned long long XXH64 (const void* input, size_t len, unsigned long long seed) +XXH_PUBLIC_API __pure unsigned long long XXH64 (const void* input, size_t len, unsigned long long seed) { #if 0 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ @@ -771,7 +790,7 @@ FORCE_INLINE U32 XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess } -XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state_in) +XXH_PUBLIC_API __pure unsigned int XXH32_digest (const XXH32_state_t* state_in) { XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; @@ -966,7 +985,7 @@ FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess } -XXH_PUBLIC_API unsigned long long XXH64_digest (const XXH64_state_t* state_in) +XXH_PUBLIC_API __pure unsigned long long XXH64_digest (const XXH64_state_t* state_in) { XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; @@ -1001,12 +1020,12 @@ XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t (void) memcpy(dst, &hash, sizeof(*dst)); } -XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src) +XXH_PUBLIC_API __pure XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src) { return XXH_readBE32(src); } -XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src) +XXH_PUBLIC_API __pure XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src) { return XXH_readBE64(src); } diff --git a/src/ulib/debug/trace.cpp b/src/ulib/debug/trace.cpp index 59681503..a0908579 100644 --- a/src/ulib/debug/trace.cpp +++ b/src/ulib/debug/trace.cpp @@ -150,6 +150,7 @@ void UTrace::trace_syscall(const char* format, uint32_t fmt_size, ...) U_INTERNAL_PRINT("buffer_syscall=%s", buffer_syscall) + /* if (active[0]) { flag_syscall_read_or_write[0] = (strncmp(format, U_CONSTANT_TO_PARAM("::read(")) == 0 || @@ -164,6 +165,7 @@ void UTrace::trace_syscall(const char* format, uint32_t fmt_size, ...) time_syscall_read_or_write->start(); } } + */ #ifdef _MSWINDOWS_ SetLastError(0); @@ -254,6 +256,7 @@ void UTrace::trace_sysreturn(bool error, const char* format, uint32_t fmt_size, if (active[0]) { + /* if (error == false && flag_syscall_read_or_write[0]) { @@ -283,6 +286,7 @@ void UTrace::trace_sysreturn(bool error, const char* format, uint32_t fmt_size, } } } + */ struct iovec iov[3] = { { (caddr_t)u_trace_tab, u_trace_num_tab }, { (caddr_t)buffer_syscall, buffer_syscall_len }, diff --git a/src/ulib/internal/common.cpp b/src/ulib/internal/common.cpp index e7331f3f..0cd901b3 100644 --- a/src/ulib/internal/common.cpp +++ b/src/ulib/internal/common.cpp @@ -44,7 +44,7 @@ U_EXPORT void operator delete[](void* p, long unsigned int) { free(p); } # endif #endif -#ifdef USE_LIBSSL +#if defined(USE_LIBSSL) && OPENSSL_VERSION_NUMBER < 0x10100000L # include # include # include @@ -227,7 +227,7 @@ void ULib_init() UString::str_allocate(0); -#ifdef USE_LIBSSL +#if defined(USE_LIBSSL) && OPENSSL_VERSION_NUMBER < 0x10100000L ULib_init_openssl(); #endif diff --git a/src/ulib/lemon/expression.cpp b/src/ulib/lemon/expression.cpp index c5b74b2b..f8df7930 100644 --- a/src/ulib/lemon/expression.cpp +++ b/src/ulib/lemon/expression.cpp @@ -484,7 +484,6 @@ static void yy_destructor( YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ - expressionParserARG_FETCH; switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen @@ -599,7 +598,7 @@ int expressionParserStackPeak(void *p){ ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ -static int yy_find_shift_action( +__pure static int yy_find_shift_action( yyParser *pParser, /* The parser */ YYCODETYPE iLookAhead /* The look-ahead token */ ){ @@ -665,7 +664,7 @@ static int yy_find_shift_action( ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ -static int yy_find_reduce_action( +__pure static int yy_find_reduce_action( int stateno, /* Current state number */ YYCODETYPE iLookAhead /* The look-ahead token */ ){ @@ -1459,7 +1458,6 @@ static void yy_reduce( break; /********** End reduce actions ************************************************/ }; - assert( yyruleno>=0 && yyrulenoyyidx -= yysize; diff --git a/src/ulib/net/server/plugin/mod_http.cpp b/src/ulib/net/server/plugin/mod_http.cpp index f74c4f42..c7a6b042 100644 --- a/src/ulib/net/server/plugin/mod_http.cpp +++ b/src/ulib/net/server/plugin/mod_http.cpp @@ -471,12 +471,14 @@ int UHttpPlugIn::handlerInit() { U_INTERNAL_DUMP("OPENSSL_VERSION_NUMBER = %ld", OPENSSL_VERSION_NUMBER) +# if OPENSSL_VERSION_NUMBER < 0x10100000L if (U_SYSCALL_NO_PARAM(SSLeay) < OPENSSL_VERSION_NUMBER) { U_ERROR("SSL: this version of mod_http was compiled against a newer library (%s, " "version currently loaded is %s) - may result in undefined or erroneous behavior", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); } +# endif /** * #ifdef OPENSSL_FIPS diff --git a/src/ulib/net/server/plugin/usp/businesses.usp b/src/ulib/net/server/plugin/usp/businesses.usp index 2dbbb34c..174217f0 100644 --- a/src/ulib/net/server/plugin/usp/businesses.usp +++ b/src/ulib/net/server/plugin/usp/businesses.usp @@ -380,8 +380,13 @@ if (USP_JFIND_REQUEST("type", type)) } else if (type.equal(U_CONSTANT_TO_PARAM("cells"))) { + BusinessCell* pcell; ResponseCells response; + U_NEW(BusinessCell, pcell, BusinessCell); + + response.businesses.push_back(pcell); + USP_JSON_OBJ_stringify(ResponseCells, response); } } diff --git a/src/ulib/net/server/plugin/usp/db.usp b/src/ulib/net/server/plugin/usp/db.usp index 818dd8a5..d940b7a0 100644 --- a/src/ulib/net/server/plugin/usp/db.usp +++ b/src/ulib/net/server/plugin/usp/db.usp @@ -31,7 +31,7 @@ static void usp_fork_db() pstmt_db->into(pworld_db->randomNumber); # ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); # endif } } diff --git a/src/ulib/net/server/plugin/usp/edb.usp b/src/ulib/net/server/plugin/usp/edb.usp index 75658002..9beabd8e 100644 --- a/src/ulib/net/server/plugin/usp/edb.usp +++ b/src/ulib/net/server/plugin/usp/edb.usp @@ -30,7 +30,7 @@ static void usp_fork_edb() U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/src/ulib/net/server/plugin/usp/equery.usp b/src/ulib/net/server/plugin/usp/equery.usp index efd42114..b02c4233 100644 --- a/src/ulib/net/server/plugin/usp/equery.usp +++ b/src/ulib/net/server/plugin/usp/equery.usp @@ -31,7 +31,7 @@ static void usp_fork_equery() U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_query, UVector(500)); #endif } diff --git a/src/ulib/net/server/plugin/usp/eupdate.usp b/src/ulib/net/server/plugin/usp/eupdate.usp index 0fb03ab6..2a0c7704 100644 --- a/src/ulib/net/server/plugin/usp/eupdate.usp +++ b/src/ulib/net/server/plugin/usp/eupdate.usp @@ -41,7 +41,7 @@ static void usp_fork_eupdate() pbuffer2 = buffer2 + QLEN; #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_update, UVector(500)); #endif } diff --git a/src/ulib/net/server/plugin/usp/mdb.usp b/src/ulib/net/server/plugin/usp/mdb.usp index 49e97e9a..659a2285 100644 --- a/src/ulib/net/server/plugin/usp/mdb.usp +++ b/src/ulib/net/server/plugin/usp/mdb.usp @@ -32,7 +32,7 @@ static void usp_fork_mdb() } #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/src/ulib/net/server/plugin/usp/mquery.usp b/src/ulib/net/server/plugin/usp/mquery.usp index 765068e2..1086abf9 100644 --- a/src/ulib/net/server/plugin/usp/mquery.usp +++ b/src/ulib/net/server/plugin/usp/mquery.usp @@ -33,7 +33,7 @@ static void usp_fork_mquery() } #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_query, UVector(500)); #endif } diff --git a/src/ulib/net/server/plugin/usp/mupdate.usp b/src/ulib/net/server/plugin/usp/mupdate.usp index eee20cfa..e1c12173 100644 --- a/src/ulib/net/server/plugin/usp/mupdate.usp +++ b/src/ulib/net/server/plugin/usp/mupdate.usp @@ -33,7 +33,7 @@ static void usp_fork_mupdate() } #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_update, UVector(500)); #endif } diff --git a/src/ulib/net/server/plugin/usp/query.usp b/src/ulib/net/server/plugin/usp/query.usp index 0e3c9e82..595d62be 100644 --- a/src/ulib/net/server/plugin/usp/query.usp +++ b/src/ulib/net/server/plugin/usp/query.usp @@ -34,7 +34,7 @@ static void usp_fork_query() pstmt_query->into(pworld_query->randomNumber); # ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_query, UVector(500)); # endif } diff --git a/src/ulib/net/server/plugin/usp/rdb.usp b/src/ulib/net/server/plugin/usp/rdb.usp index 2d87ef68..908c21e5 100644 --- a/src/ulib/net/server/plugin/usp/rdb.usp +++ b/src/ulib/net/server/plugin/usp/rdb.usp @@ -28,7 +28,7 @@ static void usp_fork_rdb() U_MEMCPY(buffer, "world:", U_CONSTANT_SIZE("world:")); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/src/ulib/net/server/plugin/usp/rquery.usp b/src/ulib/net/server/plugin/usp/rquery.usp index 6662621b..9a6cedda 100644 --- a/src/ulib/net/server/plugin/usp/rquery.usp +++ b/src/ulib/net/server/plugin/usp/rquery.usp @@ -29,7 +29,7 @@ static void usp_fork_rquery() U_NEW(UVector, pvworld_query, UVector(500)); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/src/ulib/net/server/plugin/usp/rupdate.usp b/src/ulib/net/server/plugin/usp/rupdate.usp index 86bf06f4..c2cde52b 100644 --- a/src/ulib/net/server/plugin/usp/rupdate.usp +++ b/src/ulib/net/server/plugin/usp/rupdate.usp @@ -29,7 +29,7 @@ static void usp_fork_rupdate() U_NEW(UVector, pvworld, UVector(500)); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/src/ulib/net/server/plugin/usp/update.usp b/src/ulib/net/server/plugin/usp/update.usp index 2d02563b..2f25266b 100644 --- a/src/ulib/net/server/plugin/usp/update.usp +++ b/src/ulib/net/server/plugin/usp/update.usp @@ -41,7 +41,7 @@ static void usp_fork_update() pstmt2->use( pworld_update->randomNumber, pworld_update->id); # ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_update, UVector(500)); # endif } diff --git a/src/ulib/ssl/certificate.cpp b/src/ulib/ssl/certificate.cpp index 76a9ade2..1923b60d 100644 --- a/src/ulib/ssl/certificate.cpp +++ b/src/ulib/ssl/certificate.cpp @@ -27,6 +27,10 @@ #include +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +# define ASN1_STRING_data ASN1_STRING_get0_data +#endif + bool UCertificate::verify_result; X509_STORE_CTX* UCertificate::csc; UVector* UCertificate::vcert; @@ -174,27 +178,6 @@ bool UCertificate::isSameIssuerAndSubject() const U_RETURN(false); } -UString UCertificate::getSignable(X509* _x509) -{ - U_TRACE(1, "UCertificate::getSignable(%p)", _x509) - - U_INTERNAL_ASSERT_POINTER(_x509) - - unsigned len = U_SYSCALL(i2d_X509_CINF, "%p,%p", _x509->cert_info, 0); - - UString signable(len); - - unsigned char* data = (unsigned char*) signable.data(); - - (void) U_SYSCALL(i2d_X509_CINF, "%p,%p", _x509->cert_info, &data); - -// len = u__strlen(data, __PRETTY_FUNCTION__); - - signable.size_adjust(len); - - U_RETURN_STRING(signable); -} - UString UCertificate::checkForSerialNumber(long number) { U_TRACE(1, "UCertificate::checkForSerialNumber(%ld)", number) @@ -315,48 +298,6 @@ unsigned UCertificate::getSignerCertificates(UVector& vec, STACK_ U_RETURN(result); } -// Gets X509v3 extensions as array of X509Ext objects - -int UCertificate::getExtensions(UHashMap& table) const -{ - U_TRACE(1, "UCertificate::getExtensions(%p)", &table) - - U_INTERNAL_ASSERT_POINTER(x509) - - int count = U_SYSCALL(X509_get_ext_count, "%p", x509); - - if (count > 0) - { - UString key, str; - char buffer[4096]; - - BIO* out = (BIO*) U_SYSCALL(BIO_new, "%p", BIO_s_mem()); - - for (int i = 0; i < count; ++i) - { - X509_EXTENSION* ext = X509_get_ext(x509, i); /* NO DUP - don't free! */ - - U_INTERNAL_ASSERT_POINTER(ext) - - key.assign(OBJ_nid2ln(OBJ_obj2nid(ext->object))); - - if (!X509V3_EXT_print(out, ext, 0, 0)) M_ASN1_OCTET_STRING_print(out, ext->value); - - int len = BIO_read(out, buffer, sizeof(buffer)); - - (void) str.replace(buffer, len); - - U_INTERNAL_DUMP("ext[%d] = <%V,%V>", i, key.rep, str.rep) - - table.insert(key, str); - } - - (void) U_SYSCALL(BIO_free, "%p", out); - } - - U_RETURN(count); -} - U_NO_EXPORT UString UCertificate::getRevocationURI(const void* gens) { U_TRACE(0, "UCertificate::getRevocationURI(%p)", gens) @@ -636,12 +577,22 @@ UString UCertificate::getModulus() const U_INTERNAL_ASSERT_POINTER(x509) + UString result; + const BIGNUM* bn; char buffer[4096]; EVP_PKEY* pkey = getSubjectPublicKey(); - BIGNUM* bn = (pkey->type == EVP_PKEY_RSA ? pkey->pkey.rsa->n - : pkey->pkey.dsa->pub_key); // EVP_PKEY_DSA +#if OPENSSL_VERSION_NUMBER < 0x10100000L + bn = (pkey->type == EVP_PKEY_RSA ? pkey->pkey.rsa->n + : pkey->pkey.dsa->pub_key); // EVP_PKEY_DSA +#else + RSA* rsa = EVP_PKEY_get1_RSA(pkey); + + RSA_get0_key(rsa, &bn, 0, 0); + + RSA_free(rsa); +#endif int len = U_SYSCALL(BN_bn2bin, "%p,%p", bn, (unsigned char*)buffer); @@ -651,12 +602,12 @@ UString UCertificate::getModulus() const UBase64::encode(buffer, len, x); - U_SYSCALL_VOID(EVP_PKEY_free, "%p", pkey); - - U_RETURN_STRING(x); + result = x; } - return UString::getStringNull(); + U_SYSCALL_VOID(EVP_PKEY_free, "%p", pkey); + + U_RETURN_STRING(result); } UString UCertificate::getExponent() const @@ -665,12 +616,22 @@ UString UCertificate::getExponent() const U_INTERNAL_ASSERT_POINTER(x509) + UString result; char buffer[16]; + const BIGNUM* bn; EVP_PKEY* pkey = getSubjectPublicKey(); - BIGNUM* bn = (pkey->type == EVP_PKEY_RSA ? pkey->pkey.rsa->e - : pkey->pkey.dsa->pub_key); // EVP_PKEY_DSA +#if OPENSSL_VERSION_NUMBER < 0x10100000L + bn = (pkey->type == EVP_PKEY_RSA ? pkey->pkey.rsa->e + : pkey->pkey.dsa->pub_key); // EVP_PKEY_DSA +#else + RSA* rsa = EVP_PKEY_get1_RSA(pkey); + + RSA_get0_key(rsa, 0, &bn, 0); + + RSA_free(rsa); +#endif int len = U_SYSCALL(BN_bn2bin, "%p,%p", bn, (unsigned char*)buffer); @@ -680,12 +641,12 @@ UString UCertificate::getExponent() const UBase64::encode(buffer, len, x); - U_SYSCALL_VOID(EVP_PKEY_free, "%p", pkey); - - U_RETURN_STRING(x); + result = x; } - return UString::getStringNull(); + U_SYSCALL_VOID(EVP_PKEY_free, "%p", pkey); + + U_RETURN_STRING(result); } UString UCertificate::getFileName(long hash, bool crl, bool* exist) diff --git a/src/ulib/ssl/crl.cpp b/src/ulib/ssl/crl.cpp index 2b97bb39..bab46de7 100644 --- a/src/ulib/ssl/crl.cpp +++ b/src/ulib/ssl/crl.cpp @@ -131,7 +131,12 @@ unsigned UCrl::getRevokedSerials(X509_CRL* _crl, long* revoked, unsigned sz) { if (i >= sz) break; - revoked[i++] = ASN1_INTEGER_get(rev->serialNumber); + revoked[i++] = +# if OPENSSL_VERSION_NUMBER < 0x10100000L + ASN1_INTEGER_get(rev->serialNumber); +# else + (long) X509_REVOKED_get0_serialNumber(rev); +# endif } X509_REVOKED_free(rev); @@ -223,7 +228,7 @@ time_t UCrl::getIssueTime(X509_CRL* _crl) U_INTERNAL_ASSERT_POINTER(_crl) - ASN1_UTCTIME* utctime = X509_CRL_get_lastUpdate(_crl); + const ASN1_UTCTIME* utctime = X509_CRL_get_lastUpdate(_crl); time_t result = UTimeDate::getSecondFromTime((const char*)utctime->data, true, "%2u%2u%2u%2u%2u%2uZ"); // 100212124550Z diff --git a/src/ulib/ssl/net/ssl_session.cpp b/src/ulib/ssl/net/ssl_session.cpp index e9d58ffd..68115c15 100644 --- a/src/ulib/ssl/net/ssl_session.cpp +++ b/src/ulib/ssl/net/ssl_session.cpp @@ -79,14 +79,20 @@ int USSLSession::newSession(SSL* ssl, SSL_SESSION* _sess) /* #ifdef DEBUG static FILE* fp = (FILE*) U_SYSCALL(fopen, "%S,%S", "/tmp/ssl_session.new", "a"); - if (fp) (void) U_SYSCALL(SSL_SESSION_print_fp, "%p,%p", fp, _sess); #endif */ sess = _sess; +#if OPENSSL_VERSION_NUMBER < 0x10100000L UHTTP::db_session_ssl->insertDataStorage((const char*)sess->session_id, sess->session_id_length); +#else + unsigned int idlen; + const unsigned char* id = (const unsigned char*) U_SYSCALL(SSL_SESSION_get_id, "", sess, &idlen); + + UHTTP::db_session_ssl->insertDataStorage((const char*)id, idlen); +#endif U_RETURN(0); } @@ -103,7 +109,6 @@ SSL_SESSION* USSLSession::getSession(SSL* ssl, unsigned char* id, int len, int* /* #ifdef DEBUG static FILE* fp = (FILE*) U_SYSCALL(fopen, "%S,%S", "/tmp/ssl_session.get", "a"); - if (fp) (void) U_SYSCALL(SSL_SESSION_print_fp, "%p,%p", fp, sess); #endif */ @@ -118,14 +123,22 @@ void USSLSession::removeSession(SSL_CTX* ctx, SSL_SESSION* _sess) /* #ifdef DEBUG static FILE* fp = (FILE*) U_SYSCALL(fopen, "%S,%S", "/tmp/ssl_session.del", "a"); - if (fp) (void) U_SYSCALL(SSL_SESSION_print_fp, "%p,%p", fp, _sess); #endif */ U_INTERNAL_ASSERT_POINTER(UHTTP::db_session_ssl) - int result = UHTTP::db_session_ssl->remove((const char*)_sess->session_id, (uint32_t)_sess->session_id_length); + int result; + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + result = UHTTP::db_session_ssl->remove((const char*)_sess->session_id, (uint32_t)_sess->session_id_length); +#else + unsigned int idlen; + const unsigned char* id = (const unsigned char*) U_SYSCALL(SSL_SESSION_get_id, "", sess, &idlen); + + result = UHTTP::db_session_ssl->remove((const char*)id, (uint32_t)idlen); +#endif // -2: The entry was already marked deleted in the hash-tree diff --git a/src/ulib/ssl/net/sslsocket.cpp b/src/ulib/ssl/net/sslsocket.cpp index b213d353..b71a3974 100644 --- a/src/ulib/ssl/net/sslsocket.cpp +++ b/src/ulib/ssl/net/sslsocket.cpp @@ -86,7 +86,13 @@ USSLSocket::USSLSocket(bool bSocketIsIPv6, SSL_CTX* _ctx, bool bserver) : USocke U_INTERNAL_ASSERT_POINTER(ctx) } - ctx->references++; // We don't want our destructor to delete ctx if still in use... + // We don't want our destructor to delete ctx if still in use... + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + ctx->references++; +#else + SSL_CTX_up_ref(ctx); +#endif ssl = 0; ret = renegotiations = 0; @@ -127,7 +133,9 @@ void USSLSocket::info_callback(const SSL* ssl, int where, int ret) { U_INTERNAL_DUMP("SSL_CB_HANDSHAKE_DONE") +# if OPENSSL_VERSION_NUMBER < 0x10100000L if (ssl->s3) ssl->s3->flags |= SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS; +# endif } } @@ -492,7 +500,7 @@ bool USSLSocket::setContext(const char* dh_file, const char* cert_file, const ch // These are the bit DH parameters from "Assigned Number for SKIP Protocols" // See there for how they were generated: http://www.skip-vpn.org/spec/numbers.html -#if OPENSSL_VERSION_NUMBER >= 0x10002000L +#if OPENSSL_VERSION_NUMBER >= 0x10002000L && OPENSSL_VERSION_NUMBER < 0x10100000L SSL_CTX_set_ecdh_auto(ctx, 1); #else if (useDHFile(dh_file) == false) U_RETURN(false); @@ -898,7 +906,9 @@ bool USSLSocket::askForClientCertificate() U_RETURN(false); } +#if OPENSSL_VERSION_NUMBER < 0x10100000L ssl->state = SSL_ST_ACCEPT; +#endif ret = U_SYSCALL(SSL_do_handshake, "%p", ssl); @@ -1235,7 +1245,9 @@ bool USSLSocket::setDataForStapling() if (U_SYSCALL(X509_check_issued, "%p,%p", staple.issuer, staple.cert) == X509_V_OK) { +# if OPENSSL_VERSION_NUMBER < 0x10100000L CRYPTO_add(&(staple.issuer->references), 1, CRYPTO_LOCK_X509); +# endif goto next; } diff --git a/src/ulib/ssl/pkcs10.cpp b/src/ulib/ssl/pkcs10.cpp index 340aa007..3b6134a5 100644 --- a/src/ulib/ssl/pkcs10.cpp +++ b/src/ulib/ssl/pkcs10.cpp @@ -75,27 +75,6 @@ UString UPKCS10::getSubject(X509_REQ* _request) U_RETURN_STRING(subject); } -UString UPKCS10::getSignable(X509_REQ* _request) -{ - U_TRACE(1, "UPKCS10::getSignable(%p)", _request) - - U_INTERNAL_ASSERT_POINTER(_request) - - unsigned len = U_SYSCALL(i2d_X509_REQ_INFO, "%p,%p", _request->req_info, 0); - - UString signable(len); - - unsigned char* data = (unsigned char*) signable.data(); - - (void) U_SYSCALL(i2d_X509_REQ_INFO, "%p,%p", _request->req_info, &data); - - // len = u__strlen(data, __PRETTY_FUNCTION__); - - signable.size_adjust(len); - - U_RETURN_STRING(signable); -} - UString UPKCS10::getEncoded(const char* format) const { U_TRACE(0, "UPKCS10::getEncoded(%S)", format) diff --git a/src/ulib/utility/services.cpp b/src/ulib/utility/services.cpp index b88a28cf..9a323323 100644 --- a/src/ulib/utility/services.cpp +++ b/src/ulib/utility/services.cpp @@ -540,7 +540,9 @@ ENGINE* UServices::loadEngine(const char* id, unsigned int flags) { U_TRACE(1, "UServices::loadEngine(%S,%u)", id, flags) +#if OPENSSL_VERSION_NUMBER < 0x10100000L U_SYSCALL_VOID_NO_PARAM(ENGINE_load_dynamic); +#endif ENGINE* e = (ENGINE*) U_SYSCALL(ENGINE_by_id, "%S", id); @@ -553,7 +555,7 @@ ENGINE* UServices::loadEngine(const char* id, unsigned int flags) e = 0; } - U_RETURN_POINTER(e,ENGINE); + U_RETURN_POINTER(e, ENGINE); } void UServices::releaseEngine(ENGINE* e, bool bkey) diff --git a/src/ulib/utility/uhttp.cpp b/src/ulib/utility/uhttp.cpp index 2c763eef..d8c647d3 100644 --- a/src/ulib/utility/uhttp.cpp +++ b/src/ulib/utility/uhttp.cpp @@ -164,9 +164,9 @@ UString* UHTTP::uri_strict_transport_security_mask; char UHTTP::iov_buffer[20]; struct iovec UHTTP::iov_vec[10]; # if !defined(U_CACHE_REQUEST_DISABLE) || defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST) -uint32_t UHTTP::agent_offset; -uint32_t UHTTP::request_offset; -uint32_t UHTTP::referer_offset; +uint32_t UHTTP::agent_offset; +uint32_t UHTTP::request_offset; +uint32_t UHTTP::referer_offset; # endif #endif @@ -1569,7 +1569,7 @@ __pure bool UHTTP::isValidMethod(const char* ptr) { // RFC 2616 4.1 "servers SHOULD ignore any empty line(s) received where a Request-Line is expected" - if (u__isspace(*ptr)) while (u__isspace((*++ptr))) {} + if (UNLIKELY(u__isspace(*ptr))) while (u__isspace((*++ptr))) {} // GET // HEAD @@ -2171,7 +2171,6 @@ U_NO_EXPORT bool UHTTP::readDataChunked(USocket* sk, UString* pbuffer, UString& char* out; const char* inp; const char* end; - uint32_t count; /** * If a server wants to start sending a response before knowing its total length (like with long script output), @@ -2207,7 +2206,7 @@ U_NO_EXPORT bool UHTTP::readDataChunked(USocket* sk, UString* pbuffer, UString& U_INTERNAL_ASSERT_DIFFERS(U_http_info.endHeader, 0) - count = pbuffer->find(U_CRLF2, U_http_info.endHeader, U_CONSTANT_SIZE(U_CRLF2)); + uint32_t count = pbuffer->find(U_CRLF2, U_http_info.endHeader, U_CONSTANT_SIZE(U_CRLF2)); if (count == U_NOT_FOUND) count = USocketExt::readWhileNotToken(sk, *pbuffer, U_CONSTANT_TO_PARAM(U_CRLF2), U_SSL_TIMEOUT_MS); @@ -2232,10 +2231,14 @@ U_NO_EXPORT bool UHTTP::readDataChunked(USocket* sk, UString* pbuffer, UString& do { // Decode the hexadecimal chunk size into an understandable number - uint32_t chunkSize = strtol(inp, 0, 16); + U_INTERNAL_DUMP("inp = %.20S", inp) + + uint32_t chunkSize = strtol(inp, (char**)&inp, 16); // The last chunk is followed by zero or more trailers, followed by a blank line + U_INTERNAL_DUMP("chunkSize = %u", chunkSize) + if (chunkSize == 0) { body.size_adjust(body.distance(out)); @@ -2247,13 +2250,22 @@ U_NO_EXPORT bool UHTTP::readDataChunked(USocket* sk, UString* pbuffer, UString& U_RETURN(false); } - U_INTERNAL_ASSERT(u__isxdigit(*inp)) + U_INTERNAL_DUMP("inp = %.20S", inp) - while (*inp++ != '\n') {} // discard the rest of the line + if (*++inp != '\n') + { + // discard the rest of the line + + inp = (const char*) U_SYSCALL(memchr, "%p,%C,%p", inp, '\n', pbuffer->remain(inp)); + + if (UNLIKELY(inp == 0)) U_RETURN(false); + } + + ++inp; U_MEMCPY(out, inp, chunkSize); - inp += chunkSize + 2; + inp += chunkSize + U_CONSTANT_SIZE(U_CRLF); out += chunkSize; } while (inp <= end); @@ -2411,6 +2423,257 @@ bool UHTTP::readBodyResponse(USocket* sk, UString* pbuffer, UString& body) U_RETURN(false); } +void UHTTP::setHostname(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setHostname(%.*S,%u)", len, ptr, len) + + // The difference between HTTP_HOST and U_HTTP_VHOST is that HTTP_HOST can include the «:PORT» text, and U_HTTP_VHOST only the name + + U_http_info.host = ptr; + U_http_host_len = + U_http_host_vlen = len; + + U_INTERNAL_DUMP("U_http_host_len = %u U_HTTP_HOST = %.*S", U_http_host_len, U_HTTP_HOST_TO_TRACE) + + // hostname[:port] + + for (const char* endptr = ptr+len; ptr < endptr; ++ptr) + { + if (*ptr == ':') + { + U_http_host_vlen = ptr-U_http_info.host; + + break; + } + } + + U_INTERNAL_DUMP("U_http_host_vlen = %u U_HTTP_VHOST = %.*S", U_http_host_vlen, U_HTTP_VHOST_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setRange(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setRange(%.*S,%u)", len, ptr, len) + + U_http_range_len = len; + U_http_info.range = ptr; + + U_INTERNAL_DUMP("Range = %.*S", U_HTTP_RANGE_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setCookie(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setCookie(%.*S,%u)", len, ptr, len) + + U_http_info.cookie = ptr; + U_http_info.cookie_len = len; + + U_INTERNAL_DUMP("Cookie(%u): = %.*S", U_http_info.cookie_len, U_HTTP_COOKIE_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setAccept(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setAccept(%.*S,%u)", len, ptr, len) + + U_http_info.accept = ptr; + U_http_accept_len = len; + + U_INTERNAL_DUMP("Accept: = %.*S", U_HTTP_ACCEPT_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setReferer(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setReferer(%.*S,%u)", len, ptr, len) + + U_http_info.referer = ptr; + U_http_info.referer_len = len; + + U_INTERNAL_DUMP("Referer(%u): = %.*S", U_http_info.referer_len, U_HTTP_REFERER_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setUpgrade(const char* ptr) +{ + U_TRACE(0, "UHTTP::setUpgrade(%p)", ptr) + + if (u_get_unalignedp16(ptr) != U_MULTICHAR_CONSTANT16('h','2') && + u__strncasecmp(ptr, U_CONSTANT_TO_PARAM("websocket")) == 0) + { + U_http_flag |= HTTP_IS_REQUEST_NOSTAT; + + U_INTERNAL_DUMP("U_http_websocket_len = %u U_http_is_request_nostat = %b", U_http_websocket_len, U_http_is_request_nostat) + } +} + +U_NO_EXPORT inline void UHTTP::setUserAgent(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setUserAgent(%.*S,%u)", len, ptr, len) + + U_http_info.user_agent = ptr; + U_http_info.user_agent_len = len; + + U_INTERNAL_DUMP("User-Agent: = %.*S", U_HTTP_USER_AGENT_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setConnection(const char* ptr) +{ + U_TRACE(0, "UHTTP::setConnection(%p)", ptr) + + char c = u__toupper(*ptr); + + if (c == 'C') + { + if (u__strncasecmp(ptr+1, U_CONSTANT_TO_PARAM("lose")) == 0) UClientImage_Base::setCloseConnection(); + } + else if (c == 'K') + { + if (u__strncasecmp(ptr+1, U_CONSTANT_TO_PARAM("eep-alive")) == 0) + { + U_http_flag |= HTTP_IS_KEEP_ALIVE; + + U_INTERNAL_DUMP("U_http_keep_alive = %b", U_http_keep_alive) + } + } + /* + else if (c == 'U') + { + if (u__strncasecmp(ptr+1, U_CONSTANT_TO_PARAM("pgrade")) == 0) {} + } + */ +} + +U_NO_EXPORT inline void UHTTP::setContentType(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setContentType(%.*S,%u)", len, ptr, len) + + U_http_content_type_len = len; + U_http_info.content_type = ptr; + + U_INTERNAL_DUMP("Content-Type(%u): = %.*S", U_http_content_type_len, U_HTTP_CTYPE_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setContentLength(const char* ptr1, const char* ptr2) +{ + U_TRACE(0, "UHTTP::setContentLength(%p,%p)", ptr1, ptr2) + + U_http_info.clength = u_strtoul(ptr1, ptr2); + + U_INTERNAL_DUMP("Content-Length: = %.*S U_http_info.clength = %u", ptr2-ptr1, ptr1, U_http_info.clength) + + U_INTERNAL_ASSERT_EQUALS(U_http_info.clength, (uint32_t)strtoul(ptr1, 0, 10)) +} + +U_NO_EXPORT inline void UHTTP::setAcceptEncoding(const char* ptr) +{ + U_TRACE(0, "UHTTP::setAcceptEncoding(%p)", ptr) + + ptr = (u_get_unalignedp32(ptr) == U_MULTICHAR_CONSTANT32('g','z','i','p') + ? ptr + : (const char*)u_find(ptr, 30, U_CONSTANT_TO_PARAM("gzip"))); + + if ( ptr && + u_get_unalignedp32(ptr) != U_MULTICHAR_CONSTANT32(';','q','=','0')) + { + U_http_flag |= HTTP_IS_ACCEPT_GZIP; + + U_INTERNAL_DUMP("U_http_is_accept_gzip = %b", U_http_is_accept_gzip) + } +} + +U_NO_EXPORT inline void UHTTP::setAcceptLanguage(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setAcceptLanguage(%.*S,%u)", len, ptr, len) + + U_http_accept_language_len = len; + U_http_info.accept_language = ptr; + + U_INTERNAL_DUMP("Accept-Language: = %.*S", U_HTTP_ACCEPT_LANGUAGE_TO_TRACE) +} + +U_NO_EXPORT inline void UHTTP::setIfModSince(const char* ptr) +{ + U_TRACE(0, "UHTTP::setIfModSince(%p)", ptr) + + U_http_info.if_modified_since = UTimeDate::getSecondFromTime(ptr, true); + + U_INTERNAL_DUMP("If-Modified-Since = %u", U_http_info.if_modified_since) +} + +U_NO_EXPORT void UHTTP::checkIPClient() +{ + U_TRACE_NO_PARAM(0, "UHTTP::checkIPClient()") + + U_INTERNAL_ASSERT_MAJOR(U_http_ip_client_len, 0) + + uint32_t n = 0; + + do { + if (u__islitem(U_http_info.ip_client[n])) break; + } + while (++n < (uint32_t)U_http_ip_client_len); + + U_INTERNAL_DUMP("ip_client = %.*S", n, U_http_info.ip_client) + + if (u_isIPAddr(UClientImage_Base::bIPv6, U_http_info.ip_client, n)) + { + U_INTERNAL_ASSERT_MINOR(n, U_INET_ADDRSTRLEN) + U_INTERNAL_ASSERT_EQUALS(UServer_Base::client_address, UServer_Base::csocket->cRemoteAddress.pcStrAddress) + + U_MEMCPY(UServer_Base::client_address, U_http_info.ip_client, n); + + UServer_Base::client_address[(UServer_Base::client_address_len = n)] = '\0'; + + U_INTERNAL_DUMP("UServer_Base::client_address = %.*S", U_CLIENT_ADDRESS_TO_TRACE) + } +} + +U_NO_EXPORT inline void UHTTP::setXRealIP(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setXRealIP(%.*S,%u)", len, ptr, len) + + U_http_ip_client_len = len; + U_http_info.ip_client = ptr; + + U_INTERNAL_DUMP("X-Real-IP: = %.*S", U_HTTP_IP_CLIENT_TO_TRACE) + + checkIPClient(); +} + +U_NO_EXPORT inline void UHTTP::setXForwardedFor(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setXForwardedFor(%.*S,%u)", len, ptr, len) + + U_http_ip_client_len = len; + U_http_info.ip_client = ptr; + + U_INTERNAL_DUMP("X-Forwarded-For: = %.*S", U_HTTP_IP_CLIENT_TO_TRACE) + + checkIPClient(); +} + +U_NO_EXPORT inline void UHTTP::setXHttpForwardedFor(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::setXHttpForwardedFor(%.*S,%u)", len, ptr, len) + + U_http_ip_client_len = len; + U_http_info.ip_client = ptr; + + U_INTERNAL_DUMP("X-Http-X-Forwarded-For: = %.*S", U_HTTP_IP_CLIENT_TO_TRACE) + + checkIPClient(); +} + +#define SET_POINTER_CHECK_REQUEST_FOR_HEADER \ + if (LIKELY(u_get_unalignedp16(pn) == U_MULTICHAR_CONSTANT16(':',' '))) pn += 2; \ + else \ + { \ + do { ++pn; } while (u__isblank(*pn)); \ + \ + if (UNLIKELY(pn >= pend)) return; \ + } \ + \ + pn = (const char*) memchr((ptr1 = pn), '\r', pend - pn); \ + \ + if (UNLIKELY(pn == 0)) return; + U_NO_EXPORT void UHTTP::checkRequestForHeader() { U_TRACE_NO_PARAM(0, "UHTTP::checkRequestForHeader()") @@ -2420,7 +2683,7 @@ U_NO_EXPORT void UHTTP::checkRequestForHeader() U_INTERNAL_ASSERT(*UClientImage_Base::request) U_INTERNAL_ASSERT_DIFFERS(U_http_method_type, 0) U_INTERNAL_ASSERT_MAJOR(U_http_info.endHeader, 0) - U_INTERNAL_ASSERT_EQUALS(U_line_terminator_len, 2) + U_INTERNAL_ASSERT_EQUALS(U_line_terminator_len, U_CONSTANT_SIZE(U_CRLF)) // -------------------------------- // check in header request for: @@ -2463,456 +2726,463 @@ U_NO_EXPORT void UHTTP::checkRequestForHeader() for (const char* pn = ptr + U_http_info.startHeader; pn < pend; pn += U_CONSTANT_SIZE(U_CRLF)) { - U_INTERNAL_DUMP("u__isheader(%C) = %b pn = %.20S", *pn, u__isheader(*pn), pn) + const char* p; + const char* p1; + unsigned char c; + const char* ptr1; + uint32_t remain = pend - pn; + + U_INTERNAL_DUMP("u__isheader(%C) = %b pn(%u) = %.*S", *pn, u__isheader(*pn), remain, remain, pn) if (u__isheader(*pn) == false) { - pn = (const char*) memchr(pn, '\r', pend - pn); + pn = (const char*) memchr(pn, '\r', remain); if (UNLIKELY(pn == 0)) return; // NB: we can have too much advanced... + + goto next; } + + p = pn; + + if (pn[4] == ':') // "Host:" + { + pn += 4; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('H','o','s','t')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setHostname(ptr1, pn-ptr1); + + goto next; + } + } + else if (pn[5] == ':') // "Range:" + { + pn += 5; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('R','a','n','g') && + u_get_unalignedp32(p+7) == U_MULTICHAR_CONSTANT32('b','y','t','e')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setRange(ptr1+U_CONSTANT_SIZE("bytes="), pn-ptr1-U_CONSTANT_SIZE("bytes=")); + + goto next; + } + } + else if (pn[6] == ':') // "Cookie|Accept:" + { + pn += 6; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('C','o','o','k')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setCookie(ptr1, pn-ptr1); + + goto next; + } + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('A','c','c','e')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setAccept(ptr1, pn-ptr1); + + goto next; + } + } + else if (pn[7] == ':') // "Referer|Upgrade|Cookie2:" + { + pn += 7; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('R','e','f','e')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setReferer(ptr1, pn-ptr1); + + goto next; + } + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('U','p','g','r') || + u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('u','p','g','r')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + U_INTERNAL_DUMP("Upgrade: = %.*S", pn-ptr1, ptr1) + + setUpgrade(ptr1); + + goto next; + } + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('C','o','o','k')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + U_INTERNAL_DUMP("Cookie2: = %.*S", pn-ptr1, ptr1) + + goto next; + } + } +# ifndef U_LOG_DISABLE + else if (pn[9] == ':') // "X-Real-IP:" + { + pn += 9; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('X','-','R','e')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setXRealIP(ptr1, pn-ptr1); + + goto next; + } + } +# endif + else if (pn[10] == ':') // "Connection|User-Agent:" + { + pn += 10; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('U','s','e','r')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setUserAgent(ptr1, pn-ptr1); + + goto next; + } + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('C','o','n','n')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setConnection(ptr1); + + goto next; + } + } + else if (pn[12] == ':') // "Content-Type:" + { + pn += 12; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('C','o','n','t') && + u_get_unalignedp32(p+7) == U_MULTICHAR_CONSTANT32('-','T','y','p')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setContentType(ptr1, pn-ptr1); + + goto next; + } + } + else if (pn[14] == ':') // "Content-Length:|HTTP2-Settings:" + { + pn += 14; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('C','o','n','t') && + u_get_unalignedp32(p+7) == U_MULTICHAR_CONSTANT32('-','L','e','n')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setContentLength(ptr1, pn); + + goto next; + } + + // HTTP2-Settings + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('H','T','T','P') || + u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('h','t','t','p')) + { + p1 = p+4; + + if (u_get_unalignedp64(p1) == U_MULTICHAR_CONSTANT64('2','-','S','e','t','t','i','n') || + u_get_unalignedp64(p1) == U_MULTICHAR_CONSTANT64('2','-','s','e','t','t','i','n')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + U_INTERNAL_DUMP("HTTP2-Settings: = %.*S", pn-ptr1, ptr1) + +# ifndef U_HTTP2_DISABLE + U_http2_settings_len = pn-ptr1; + UHTTP2::upgrade_settings = ptr1; + + U_http_version = '2'; + U_ClientImage_data_missing = true; +# endif + + goto next; + } + } + } + else if (pn[15] == ':') // "Accept-Encoding/Language|X-Forwarded-For:" + { + pn += 15; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('A','c','c','e')) + { + p1 = p+6; + + if (u_get_unalignedp32(p1) == U_MULTICHAR_CONSTANT32('-','E','n','c')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + U_INTERNAL_DUMP("Accept-Encoding: = %.*S", pn-ptr1, ptr1) + +# ifdef USE_LIBZ + setAcceptEncoding(ptr1); +# endif + + goto next; + } + + if (u_get_unalignedp32(p1) == U_MULTICHAR_CONSTANT32('-','L','a','n')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setAcceptLanguage(ptr1, pn-ptr1); + + goto next; + } + } + +# ifndef U_LOG_DISABLE + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('X','-','F','o')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setXForwardedFor(ptr1, pn-ptr1); + + goto next; + } +# endif + } + else if (pn[17] == ':') // "If-Modified-Since|Sec-WebSocket-Key:" + { + pn += 17; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('I','f','-','M')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setIfModSince(ptr1); + + goto next; + } + + if (u_get_unalignedp64(p) == U_MULTICHAR_CONSTANT64('S','e','c','-','W','e','b','S') && + u_get_unalignedp64(p+8) == U_MULTICHAR_CONSTANT64('o','c','k','e','t','-','K','e')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + U_http_websocket_len = pn-ptr1; + UWebSocket::upgrade_settings = ptr1; + + U_INTERNAL_DUMP("Sec-WebSocket-Key: = %.*S", U_http_websocket_len, UWebSocket::upgrade_settings) + + goto next; + } + } +# ifndef U_LOG_DISABLE + else if (pn[22] == ':') // "X-Http-X-Forwarded-For:" + { + pn += 22; + + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('X','-','H','t')) + { + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + setXHttpForwardedFor(ptr1, pn-ptr1); + + goto next; + } + } +# endif else { - const char* p; - const char* p1; - uint32_t pos1, pos2; - unsigned char c = *(p = pn), c1; - - if (pn[ 4] == ':') pn += 4; // "Host:" - else if (pn[ 5] == ':') pn += 5; // "Range:" - else if (pn[ 6] == ':') pn += 6; // "Cookie|Accept:" - else if (pn[ 7] == ':') pn += 7; // "Referer|Upgrade:" -# ifndef U_LOG_DISABLE - else if (pn[ 9] == ':') pn += 9; // "X-Real-IP:" -# endif - else if (pn[10] == ':') pn += 10; // "Connection|User-Agent:" - else if (pn[12] == ':') pn += 12; // "Content-Type:" - else if (pn[14] == ':') pn += 14; // "Content-Length:|HTTP2-Settings:" -# if !defined(U_LOG_DISABLE) || defined(USE_LIBZ) - else if (pn[15] == ':') pn += 15; // "Accept-Encoding/Language|X-Forwarded-For:" -# endif - else if (pn[17] == ':') pn += 17; // "If-Modified-Since|Sec-WebSocket-Key:" - else - { - do { ++pn; } while (u__isename(*pn) == false); - - if (UNLIKELY(pn >= pend)) return; // NB: we can have too much advanced... - - if (UNLIKELY(u_get_unalignedp16(pn) == U_MULTICHAR_CONSTANT16('\r','\n'))) goto next; - - goto advance; - } - - if (UNLIKELY(pn >= pend)) return; // NB: we can have too much advanced... - -advance: U_INTERNAL_ASSERT_EQUALS(*pn, ':') - - if (LIKELY(u_get_unalignedp16(pn) == U_MULTICHAR_CONSTANT16(':',' '))) pn += 2; - else - { - do { ++pn; } while (u__isblank(*pn)); - - if (UNLIKELY(pn >= pend)) return; // NB: we can have too much advanced... - } - - pos1 = pn-ptr; - - pn = (const char*) memchr(pn, '\r', pend - pn); + pn = (const char*) memchr(pn, ':', remain); if (UNLIKELY(pn == 0)) return; // NB: we can have too much advanced... - - pos2 = pn-ptr; - - U_INTERNAL_DUMP("pos1 = %.20S", ptr+pos1) - U_INTERNAL_DUMP("pos2 = %.20S", ptr+pos2) - - switch (u_get_unalignedp32(p)) - { - case U_MULTICHAR_CONSTANT32('R','a','n','g'): - { - if (u_get_unalignedp32(ptr+pos1) == U_MULTICHAR_CONSTANT32('b','y','t','e')) goto set_range; - } - break; - case U_MULTICHAR_CONSTANT32('S','e','c','-'): // Sec-WebSocket-Key - { - if (u_get_unalignedp32(p+4) == U_MULTICHAR_CONSTANT32('W','e','b','S') && - u_get_unalignedp32(p+8) == U_MULTICHAR_CONSTANT32('o','c','k','e') && - u_get_unalignedp32(p+12) == U_MULTICHAR_CONSTANT32('t','-','K','e')) - { - U_http_websocket_len = pos2-pos1; - UWebSocket::upgrade_settings = ptr+pos1; - - U_INTERNAL_DUMP("Sec-WebSocket-Key: = %.*S", U_http_websocket_len, UWebSocket::upgrade_settings) - - goto next; - } - } - break; -# ifndef U_HTTP2_DISABLE - case U_MULTICHAR_CONSTANT32('H','T','T','P'): - case U_MULTICHAR_CONSTANT32('h','t','t','p'): - { - // HTTP2-Settings - - if (u_get_unalignedp64(p+4) == U_MULTICHAR_CONSTANT64('2','-','S','e','t','t','i','n') || - u_get_unalignedp64(p+4) == U_MULTICHAR_CONSTANT64('2','-','s','e','t','t','i','n')) - { - U_http2_settings_len = pos2-pos1; - UHTTP2::upgrade_settings = ptr+pos1; - - U_INTERNAL_DUMP("HTTP2-Settings: = %.*S", U_http2_settings_len, UHTTP2::upgrade_settings) - - U_http_version = '2'; - U_ClientImage_data_missing = true; - - goto next; - } - } - break; -# endif - case U_MULTICHAR_CONSTANT32('C','o','n','t'): - { - if (u_get_unalignedp32(p+7) == U_MULTICHAR_CONSTANT32('-','T','y','p')) goto set_content_type; - if (u_get_unalignedp32(p+7) == U_MULTICHAR_CONSTANT32('-','L','e','n')) goto set_content_length; - } - break; - case U_MULTICHAR_CONSTANT32('C','o','n','n'): - { - if (u_get_unalignedp32(ptr+pos1) == U_MULTICHAR_CONSTANT32('c','l','o','s')) - { - UClientImage_Base::setCloseConnection(); - - goto next; - } - - if (u_get_unalignedp32(ptr+pos1) == U_MULTICHAR_CONSTANT32('k','e','e','p') || - u_get_unalignedp32(ptr+pos1) == U_MULTICHAR_CONSTANT32('K','e','e','p')) - { - goto set_connection_kalive; - } - - /* - if (u_get_unalignedp32(ptr+pos1) == U_MULTICHAR_CONSTANT32('u','p','g','r') || - u_get_unalignedp32(ptr+pos1) == U_MULTICHAR_CONSTANT32('U','p','g','r')) - { - goto set_connection_upgrade; - } - */ - } - break; -# ifdef USE_LIBZ - case U_MULTICHAR_CONSTANT32('A','c','c','e'): - { - if (u_get_unalignedp32(p+6) == U_MULTICHAR_CONSTANT32('-','E','n','c')) goto set_accept_encoding; - if (u_get_unalignedp32(p+6) == U_MULTICHAR_CONSTANT32('-','L','a','n')) goto set_accept_language; - - goto set_accept; - } - // break; // it is intentional... -# endif - case U_MULTICHAR_CONSTANT32('C','o','o','k'): goto set_cookie; - case U_MULTICHAR_CONSTANT32('H','o','s','t'): goto set_hostname; - case U_MULTICHAR_CONSTANT32('U','s','e','r'): goto set_user_agent; - case U_MULTICHAR_CONSTANT32('u','p','g','r'): - case U_MULTICHAR_CONSTANT32('U','p','g','r'): goto set_upgrade; - case U_MULTICHAR_CONSTANT32('I','f','-','M'): goto set_if_mod_since; -# ifndef U_LOG_DISABLE - case U_MULTICHAR_CONSTANT32('R','e','f','e'): goto set_referer; - case U_MULTICHAR_CONSTANT32('X','-','F','o'): goto set_x_forwarded_for; - case U_MULTICHAR_CONSTANT32('X','-','R','e'): goto set_x_real_ip; - case U_MULTICHAR_CONSTANT32('X','-','H','t'): goto set_x_http_forward_for; -# endif - } - - ++p; - - switch (u__toupper(c)) - { - case 'C': - { - if (memcmp(p, U_CONSTANT_TO_PARAM("ontent-")) == 0) - { - p1 = p+8; - c1 = u__toupper(*(p1-1)); - - if (c1 == 'T' && - memcmp(p1, U_CONSTANT_TO_PARAM("ype")) == 0) - { -set_content_type: U_http_content_type_len = pos2-pos1; - U_http_info.content_type = ptr+pos1; - - U_INTERNAL_DUMP("Content-Type(%u): = %.*S", U_http_content_type_len, U_HTTP_CTYPE_TO_TRACE) - } - else if (c1 == 'L' && - memcmp(p1, U_CONSTANT_TO_PARAM("ength")) == 0) - { -set_content_length: U_http_info.clength = (uint32_t) strtoul(ptr+pos1, 0, 10); - - U_INTERNAL_DUMP("Content-Length: = %.*S U_http_info.clength = %u", 10, ptr+pos1, U_http_info.clength) - } - } - else if (memcmp(p, U_CONSTANT_TO_PARAM("onnection")) == 0) - { - p1 = ptr+pos1; - - U_INTERNAL_DUMP("Connection: = %.*S", pos2-pos1, p1) - - c1 = u__toupper(*p1); - - if (c1 == 'C') - { - if (u__strncasecmp(p1+1, U_CONSTANT_TO_PARAM("lose")) == 0) UClientImage_Base::setCloseConnection(); - } - else if (c1 == 'K') - { - if (u__strncasecmp(p1+1, U_CONSTANT_TO_PARAM("eep-alive")) == 0) - { -set_connection_kalive: U_http_flag |= HTTP_IS_KEEP_ALIVE; - - U_INTERNAL_DUMP("U_http_keep_alive = %b", U_http_keep_alive) - } - } - /* - else if (c1 == 'U') - { - if (u__strncasecmp(p1+1, U_CONSTANT_TO_PARAM("pgrade")) == 0) - { -set_connection_upgrade: - } - } - */ - } - else if (memcmp(p, U_CONSTANT_TO_PARAM("ookie")) == 0) - { - U_INTERNAL_ASSERT_DIFFERS(p[5], '2') // "Cookie2" - -set_cookie: U_http_info.cookie = ptr+pos1; - U_http_info.cookie_len = pos2-pos1; - - U_INTERNAL_DUMP("Cookie(%u): = %.*S", U_http_info.cookie_len, U_HTTP_COOKIE_TO_TRACE) - } - } - break; - -# ifdef USE_LIBZ - case 'A': - { - if (memcmp(p, U_CONSTANT_TO_PARAM("ccept")) == 0) - { - if (p[5] == '-') - { - p1 = p+7; - c1 = u__toupper(*(p1-1)); - - if (c1 == 'E' && - memcmp(p1, U_CONSTANT_TO_PARAM("ncoding")) == 0) - { -set_accept_encoding: p1 = ptr+pos1; - - U_INTERNAL_DUMP("Accept-Encoding: = %.*S", pos2-pos1, p1) - - const char* p2 = (u_get_unalignedp32(p1) == U_MULTICHAR_CONSTANT32('g','z','i','p') - ? p1 - : (const char*)u_find(p1, 30, U_CONSTANT_TO_PARAM("gzip"))); - - if ( p2 && - u_get_unalignedp32(p2) != U_MULTICHAR_CONSTANT32(';','q','=','0')) - { - U_http_flag |= HTTP_IS_ACCEPT_GZIP; - - U_INTERNAL_DUMP("U_http_is_accept_gzip = %b", U_http_is_accept_gzip) - } - } - else if (c1 == 'L' && - memcmp(p1, U_CONSTANT_TO_PARAM("anguage")) == 0) - { -set_accept_language: U_http_accept_language_len = pos2-pos1; - U_http_info.accept_language = ptr+pos1; - - U_INTERNAL_DUMP("Accept-Language: = %.*S", U_HTTP_ACCEPT_LANGUAGE_TO_TRACE) - } - } - else - { -set_accept: U_http_info.accept = ptr+pos1; - U_http_accept_len = pos2-pos1; - - U_INTERNAL_DUMP("Accept: = %.*S", U_HTTP_ACCEPT_TO_TRACE) - } - } - } - break; -# endif - - case 'H': - { - if (memcmp(p, U_CONSTANT_TO_PARAM("ost")) == 0 || - (u__toupper(p[0]) == 'O' && - u__toupper(p[1]) == 'S' && - u__toupper(p[2]) == 'T')) - { -set_hostname: setHostname(ptr+pos1, pos2-pos1); - } - } - break; - - case 'U': - { - if (u__toupper(p[4]) == 'A' && - u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('s','e','r','-') && - u_get_unalignedp32(p+5) == U_MULTICHAR_CONSTANT32('g','e','n','t')) - { -set_user_agent: U_http_info.user_agent = ptr+pos1; - U_http_info.user_agent_len = pos2-pos1; - - U_INTERNAL_DUMP("User-Agent: = %.*S", U_HTTP_USER_AGENT_TO_TRACE) - } - else if (memcmp(p, U_CONSTANT_TO_PARAM("pgrade")) == 0) - { -set_upgrade: p1 = ptr+pos1; - - U_INTERNAL_DUMP("Upgrade: = %.*S", pos2-pos1, p1) - - if (u_get_unalignedp16(p1) != U_MULTICHAR_CONSTANT16('h','2') && - u__strncasecmp(p1, U_CONSTANT_TO_PARAM("websocket")) == 0) - { - U_http_flag |= HTTP_IS_REQUEST_NOSTAT; - - U_INTERNAL_DUMP("U_http_websocket_len = %u U_http_is_request_nostat = %b", U_http_websocket_len, U_http_is_request_nostat) - } - } - } - break; - - case 'I': // If-Modified-Since - { - if (u__toupper(p[2]) == 'M' && - u__toupper(p[11]) == 'S' && - u_get_unalignedp16(p) == U_MULTICHAR_CONSTANT16('f','-') && - u_get_unalignedp64(p+3) == U_MULTICHAR_CONSTANT64('o','d','i','f','i','e','d','-') && - u_get_unalignedp32(p+12) == U_MULTICHAR_CONSTANT32('i','n','c','e')) - { -set_if_mod_since: U_http_info.if_modified_since = UTimeDate::getSecondFromTime(ptr+pos1, true); - - U_INTERNAL_DUMP("If-Modified-Since = %u", U_http_info.if_modified_since) - } - } - break; - - case 'R': - { - if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('a','n','g','e') && - u_get_unalignedp32(ptr+pos1) == U_MULTICHAR_CONSTANT32('b','y','t','e') && - u_get_unalignedp16(ptr+pos1+4) == U_MULTICHAR_CONSTANT16('s','=')) - { -set_range: U_http_info.range = ptr+pos1+U_CONSTANT_SIZE("bytes="); - U_http_range_len = pos2-pos1-U_CONSTANT_SIZE("bytes="); - - U_INTERNAL_DUMP("Range = %.*S", U_HTTP_RANGE_TO_TRACE) - } -# ifndef U_LOG_DISABLE - if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('e','f','e','r') && - u_get_unalignedp16(p+4) == U_MULTICHAR_CONSTANT16('e','r')) - { -set_referer: U_http_info.referer = ptr+pos1; - U_http_info.referer_len = pos2-pos1; - - U_INTERNAL_DUMP("Referer(%u): = %.*S", U_http_info.referer_len, U_HTTP_REFERER_TO_TRACE) - } -# endif - } - break; - -# ifndef U_LOG_DISABLE - case 'X': - { - if (p[0] == '-') - { - c1 = u__toupper(p[1]); - - // TODO: check of CLIENT-IP, WEBPROXY-REMOTE-ADDR, FORWARDED... - - if (c1 == 'F') // "X-Forwarded-For" - { - if (u__toupper(p[11]) == 'F' && - memcmp(p+2, U_CONSTANT_TO_PARAM("orwarded-")) == 0 && - u_get_unalignedp16(p+12) == U_MULTICHAR_CONSTANT16('o','r')) - { -set_x_forwarded_for: U_http_info.ip_client = ptr+pos1; - U_http_ip_client_len = pos2-pos1; - - U_INTERNAL_DUMP("X-Forwarded-For: = %.*S", U_HTTP_IP_CLIENT_TO_TRACE) - } - } - else if (c1 == 'R') // "X-Real-IP" - { - if (u__toupper(p[6]) == 'I' && - u__toupper(p[7]) == 'P' && - u_get_unalignedp32(p+2) == U_MULTICHAR_CONSTANT32('e','a','l','-')) - { -set_x_real_ip: U_http_info.ip_client = ptr+pos1; - U_http_ip_client_len = pos2-pos1; - - U_INTERNAL_DUMP("X-Real-IP: = %.*S", U_HTTP_IP_CLIENT_TO_TRACE) - } - } - else if (c1 == 'H') // "X-Http-X-Forwarded-For" - { - if (u__toupper(p[2]) == 'T' && - u__toupper(p[3]) == 'T' && - u__toupper(p[4]) == 'P' && - u__toupper(p[18]) == 'F' && - memcmp(p+9, U_CONSTANT_TO_PARAM("orwarded-")) == 0 && - u_get_unalignedp16(p+19) == U_MULTICHAR_CONSTANT16('o','r')) - { -set_x_http_forward_for: U_http_info.ip_client = ptr+pos1; - U_http_ip_client_len = pos2-pos1; - - U_INTERNAL_DUMP("X-Http-X-Forwarded-For: = %.*S", U_HTTP_IP_CLIENT_TO_TRACE) - } - } - - if (U_http_ip_client_len) - { - uint32_t n = 0; - - p1 = U_http_info.ip_client; - - do { - if (u__islitem(p1[n])) break; - } - while (++n < (uint32_t)U_http_ip_client_len); - - U_INTERNAL_DUMP("ip_client = %.*S", n, U_http_info.ip_client) - - if (u_isIPAddr(UClientImage_Base::bIPv6, U_http_info.ip_client, n)) - { - U_INTERNAL_ASSERT_MINOR(n, U_INET_ADDRSTRLEN) - U_INTERNAL_ASSERT_EQUALS(UServer_Base::client_address, UServer_Base::csocket->cRemoteAddress.pcStrAddress) - - U_MEMCPY(UServer_Base::client_address, U_http_info.ip_client, n); - - UServer_Base::client_address[(UServer_Base::client_address_len = n)] = '\0'; - - U_INTERNAL_DUMP("UServer_Base::client_address = %.*S", U_CLIENT_ADDRESS_TO_TRACE) - } - } - } - } - break; -# endif - } } -next: - U_INTERNAL_DUMP("char (after cr/newline) = %C U_http_version = %C U_ClientImage_data_missing = %b", pn[2], U_http_version, U_ClientImage_data_missing) + SET_POINTER_CHECK_REQUEST_FOR_HEADER + + switch (u__toupper(*p++)) + { + case 'C': + { + if (memcmp(p, U_CONSTANT_TO_PARAM("ontent-")) == 0) + { + p1 = p+8; + c = u__toupper(*(p1-1)); + + if (c == 'T' && + memcmp(p1, U_CONSTANT_TO_PARAM("ype")) == 0) + { + setContentType(ptr1, pn-ptr1); + } + else if (c == 'L' && + memcmp(p1, U_CONSTANT_TO_PARAM("ength")) == 0) + { + setContentLength(ptr1, pn); + } + } + else if (memcmp(p, U_CONSTANT_TO_PARAM("onnection")) == 0) + { + setConnection(ptr1); + } + else if (memcmp(p, U_CONSTANT_TO_PARAM("ookie")) == 0) + { + U_INTERNAL_ASSERT_DIFFERS(p[5], '2') // "Cookie2" + + setCookie(ptr1, pn-ptr1); + } + } + break; + + case 'A': + { + if (memcmp(p, U_CONSTANT_TO_PARAM("ccept")) == 0) + { + if (p[5] == '-') + { + p1 = p+7; + c = u__toupper(*(p1-1)); + + if (c == 'E' && + memcmp(p1, U_CONSTANT_TO_PARAM("ncoding")) == 0) + { + U_INTERNAL_DUMP("Accept-Encoding: = %.*S", pn-ptr1, ptr1) + + setAcceptEncoding(ptr1); + } + else if (c == 'L' && + memcmp(ptr1, U_CONSTANT_TO_PARAM("anguage")) == 0) + { + setAcceptLanguage(ptr1, pn-ptr1); + } + } + else + { + setAccept(ptr1, pn-ptr1); + } + } + } + break; + + case 'H': + { + if (memcmp(p, U_CONSTANT_TO_PARAM("ost")) == 0 || + (u__toupper(p[0]) == 'O' && + u__toupper(p[1]) == 'S' && + u__toupper(p[2]) == 'T')) + { + setHostname(ptr1, pn-ptr1); + } + } + break; + + case 'U': + { + if (u__toupper(p[4]) == 'A' && + u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('s','e','r','-') && + u_get_unalignedp32(p+5) == U_MULTICHAR_CONSTANT32('g','e','n','t')) + { + setUserAgent(ptr1, pn-ptr1); + } + else if (memcmp(p, U_CONSTANT_TO_PARAM("pgrade")) == 0) + { + U_INTERNAL_DUMP("Upgrade: = %.*S", pn-ptr1, ptr1) + + setUpgrade(ptr1); + } + } + break; + + case 'I': // If-Modified-Since + { + if (u__toupper(p[2]) == 'M' && + u__toupper(p[11]) == 'S' && + u_get_unalignedp16(p) == U_MULTICHAR_CONSTANT16('f','-') && + u_get_unalignedp64(p+3) == U_MULTICHAR_CONSTANT64('o','d','i','f','i','e','d','-') && + u_get_unalignedp32(p+12) == U_MULTICHAR_CONSTANT32('i','n','c','e')) + { + setIfModSince(ptr1); + } + } + break; + + case 'R': + { + if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('a','n','g','e') && + u_get_unalignedp32(ptr1) == U_MULTICHAR_CONSTANT32('b','y','t','e') && + u_get_unalignedp16(ptr1+4) == U_MULTICHAR_CONSTANT16('s','=')) + { + setRange(ptr1+U_CONSTANT_SIZE("bytes="), pn-ptr1-U_CONSTANT_SIZE("bytes=")); + } + else if (u_get_unalignedp32(p) == U_MULTICHAR_CONSTANT32('e','f','e','r') && + u_get_unalignedp16(p+4) == U_MULTICHAR_CONSTANT16('e','r')) + { + setReferer(ptr1, pn-ptr1); + } + } + break; + +# ifndef U_LOG_DISABLE + case 'X': + { + if (p[0] == '-') + { + c = u__toupper(p[1]); + + // TODO: check of CLIENT-IP, WEBPROXY-REMOTE-ADDR, FORWARDED... + + if (c == 'F') // "X-Forwarded-For" + { + if (u__toupper(p[11]) == 'F' && + memcmp(p+2, U_CONSTANT_TO_PARAM("orwarded-")) == 0 && + u_get_unalignedp16(p+12) == U_MULTICHAR_CONSTANT16('o','r')) + { + setXForwardedFor(ptr1, pn-ptr1); + } + } + else if (c == 'R') // "X-Real-IP" + { + if (u__toupper(p[6]) == 'I' && + u__toupper(p[7]) == 'P' && + u_get_unalignedp32(p+2) == U_MULTICHAR_CONSTANT32('e','a','l','-')) + { + setXRealIP(ptr1, pn-ptr1); + } + } + else if (c == 'H') // "X-Http-X-Forwarded-For" + { + if (u__toupper(p[2]) == 'T' && + u__toupper(p[3]) == 'T' && + u__toupper(p[4]) == 'P' && + u__toupper(p[18]) == 'F' && + memcmp(p+9, U_CONSTANT_TO_PARAM("orwarded-")) == 0 && + u_get_unalignedp16(p+19) == U_MULTICHAR_CONSTANT16('o','r')) + { + setXHttpForwardedFor(ptr1, pn-ptr1); + } + } + } + } + break; +# endif + } + +next: U_INTERNAL_DUMP("char (after cr/newline) = %C U_http_version = %C U_ClientImage_data_missing = %b", pn[2], U_http_version, U_ClientImage_data_missing) if (U_http_info.endHeader == 0 && u_get_unalignedp32(pn) == U_MULTICHAR_CONSTANT32('\r','\n','\r','\n')) { - uint32_t pos = pn-ptr; - - U_http_info.endHeader = pos + U_CONSTANT_SIZE(U_CRLF2); // NB: U_http_info.endHeader includes also the blank line... + U_http_info.endHeader = pn-ptr + U_CONSTANT_SIZE(U_CRLF2); // NB: U_http_info.endHeader includes also the blank line... U_INTERNAL_DUMP("endHeader(%u) = %.20S", U_http_info.endHeader, ptr+U_http_info.endHeader) @@ -4806,9 +5076,15 @@ void UHTTP::initSessionSSL() * be explicitly freed with SSL_SESSION_free(3) */ - U_SYSCALL_VOID(SSL_CTX_sess_set_new_cb, "%p,%p", USSLSocket::sctx, USSLSession::newSession); - U_SYSCALL_VOID(SSL_CTX_sess_set_get_cb, "%p,%p", USSLSocket::sctx, USSLSession::getSession); - U_SYSCALL_VOID(SSL_CTX_sess_set_remove_cb, "%p,%p", USSLSocket::sctx, USSLSession::removeSession); +#if OPENSSL_VERSION_NUMBER < 0x10100000L +typedef SSL_SESSION* (*psPFpspcipi) (SSL*, unsigned char*,int,int*); +#else +typedef SSL_SESSION* (*psPFpspcipi) (SSL*,const unsigned char*,int,int*); +#endif + + U_SYSCALL_VOID(SSL_CTX_sess_set_new_cb, "%p,%p", USSLSocket::sctx, USSLSession::newSession); + U_SYSCALL_VOID(SSL_CTX_sess_set_get_cb, "%p,%p", USSLSocket::sctx, (psPFpspcipi)USSLSession::getSession); + U_SYSCALL_VOID(SSL_CTX_sess_set_remove_cb, "%p,%p", USSLSocket::sctx, USSLSession::removeSession); // NB: All currently supported protocols have the same default timeout value of 300 seconds // ---------------------------------------------------------------------------------------- diff --git a/tests/Makefile.am b/tests/Makefile.am index 1813d857..d8e6c819 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,7 +12,7 @@ SUBDIRS1 += debug endif SUBDIRS = $(SUBDIRS1) ulib if ENABLE_EXAMPLES -SUBDIRS += examples contrib +SUBDIRS += examples endif DIST_SUBDIRS = base debug ulib examples contrib diff --git a/tests/Makefile.in b/tests/Makefile.in index c4adb32c..8c59e7dc 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -89,7 +89,7 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ @DEBUG_TRUE@am__append_1 = debug -@ENABLE_EXAMPLES_TRUE@am__append_2 = examples contrib +@ENABLE_EXAMPLES_TRUE@am__append_2 = examples subdir = tests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_package.m4 \ diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp index 818dd8a5..d940b7a0 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/db.usp @@ -31,7 +31,7 @@ static void usp_fork_db() pstmt_db->into(pworld_db->randomNumber); # ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); # endif } } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/edb.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/edb.usp index 75658002..9beabd8e 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/edb.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/edb.usp @@ -30,7 +30,7 @@ static void usp_fork_edb() U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/equery.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/equery.usp index efd42114..b02c4233 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/equery.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/equery.usp @@ -31,7 +31,7 @@ static void usp_fork_equery() U_MEMCPY(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_query, UVector(500)); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/eupdate.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/eupdate.usp index 0fb03ab6..2a0c7704 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/eupdate.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/eupdate.usp @@ -41,7 +41,7 @@ static void usp_fork_eupdate() pbuffer2 = buffer2 + QLEN; #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_update, UVector(500)); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mdb.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mdb.usp index 49e97e9a..659a2285 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mdb.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mdb.usp @@ -32,7 +32,7 @@ static void usp_fork_mdb() } #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mquery.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mquery.usp index 765068e2..1086abf9 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mquery.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mquery.usp @@ -33,7 +33,7 @@ static void usp_fork_mquery() } #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_query, UVector(500)); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mupdate.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mupdate.usp index eee20cfa..e1c12173 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mupdate.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/mupdate.usp @@ -33,7 +33,7 @@ static void usp_fork_mupdate() } #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_update, UVector(500)); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp index 0e3c9e82..595d62be 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/query.usp @@ -34,7 +34,7 @@ static void usp_fork_query() pstmt_query->into(pworld_query->randomNumber); # ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_query, UVector(500)); # endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rdb.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rdb.usp index 2d87ef68..908c21e5 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rdb.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rdb.usp @@ -28,7 +28,7 @@ static void usp_fork_rdb() U_MEMCPY(buffer, "world:", U_CONSTANT_SIZE("world:")); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(OBJECT_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rquery.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rquery.usp index 6662621b..9a6cedda 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rquery.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rquery.usp @@ -29,7 +29,7 @@ static void usp_fork_rquery() U_NEW(UVector, pvworld_query, UVector(500)); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rupdate.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rupdate.usp index 86bf06f4..c2cde52b 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rupdate.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/rupdate.usp @@ -29,7 +29,7 @@ static void usp_fork_rupdate() U_NEW(UVector, pvworld, UVector(500)); #ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); #endif } diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/update.usp b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/update.usp index aeefb6fd..2f25266b 100644 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/update.usp +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/src/update.usp @@ -32,6 +32,8 @@ static void usp_fork_update() U_WARNING("usp_fork_update(): we cound't connect to db"); } + if (UOrmDriver::isPGSQL()) *psql_update << "SET synchronous_commit TO OFF"; + U_NEW(World, pworld_update, World); pstmt1->use( pworld_update->id); @@ -39,7 +41,7 @@ static void usp_fork_update() pstmt2->use( pworld_update->randomNumber, pworld_update->id); # ifndef AS_cpoll_cppsp_DO - U_NEW(UValue, pvalue, UValue(ARRAY_VALUE)); + U_NEW(UValue, pvalue, UValue); U_NEW(UVector, pvworld_update, UVector(500)); # endif } diff --git a/tests/examples/tsa_https.test b/tests/examples/tsa_https.test index a5913ccd..e14b07fc 100755 --- a/tests/examples/tsa_https.test +++ b/tests/examples/tsa_https.test @@ -57,7 +57,7 @@ rm -rf $DOC_ROOT/*log \ CAPATH="../ulib/CA/CApath" CACERT="../ulib/CA/username.crt" USER_KEY="../ulib/CA/username.key" -LCMD="$OPENSSL s_client -no_ssl2 -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -verify 0 -connect localhost:443" +LCMD="$OPENSSL s_client -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -connect localhost:443" creat_link . $DOC_ROOT/$DOC_ROOT diff --git a/tests/examples/tsa_rpc.test b/tests/examples/tsa_rpc.test index 57f5bf7e..7623f58c 100755 --- a/tests/examples/tsa_rpc.test +++ b/tests/examples/tsa_rpc.test @@ -22,7 +22,7 @@ rm -rf $DOC_ROOT/*log \ CAPATH="../ulib/CA/CApath" CACERT="../ulib/CA/username.crt" USER_KEY="../ulib/CA/username.key" -LCMD="$OPENSSL s_client -no_ssl2 -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -verify 0 -connect localhost:443" +LCMD="$OPENSSL s_client -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -connect localhost:443" creat_link . $DOC_ROOT/$DOC_ROOT diff --git a/tests/examples/tsa_ssoap.test b/tests/examples/tsa_ssoap.test index 46675b81..7074a302 100755 --- a/tests/examples/tsa_ssoap.test +++ b/tests/examples/tsa_ssoap.test @@ -56,7 +56,7 @@ rm -rf $DOC_ROOT/*log \ CAPATH="../ulib/CA/CApath" CACERT="../ulib/CA/username.crt" USER_KEY="../ulib/CA/username.key" -LCMD="$OPENSSL s_client -no_ssl2 -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -verify 0 -connect localhost:443" +LCMD="$OPENSSL s_client -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -connect localhost:443" creat_link . $DOC_ROOT/$DOC_ROOT diff --git a/tests/examples/web_server_ssl.test b/tests/examples/web_server_ssl.test index 84861f1e..f5b89497 100755 --- a/tests/examples/web_server_ssl.test +++ b/tests/examples/web_server_ssl.test @@ -39,7 +39,7 @@ check_for_netcat CAPATH="../ulib/CA/CApath" CACERT="../ulib/CA/username.crt" USER_KEY="../ulib/CA/username.key" -LCMD="$OPENSSL s_client -no_ssl2 -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -verify 0 -connect" +LCMD="$OPENSSL s_client -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -connect" LCMD1="$LCMD localhost:4443" # function : start_test diff --git a/tests/ulib/README b/tests/ulib/README index 298f3cd3..c29ca99f 100644 --- a/tests/ulib/README +++ b/tests/ulib/README @@ -4,8 +4,8 @@ Four Debian releases are available on the main site: Debian 7.11, or wheezy. Access this release through dists/oldstable Debian 7.11 was released Saturday, 4th June 2016. -Debian 8.5, or jessie. Access this release through dists/stable -Debian 8.5 was released Saturday, 4th June 2016. +Debian 8.6, or jessie. Access this release through dists/stable +Debian 8.6 was released Saturday, 17th September 2016. Testing, or stretch. Access this release through dists/testing. The current tested development snapshot is named stretch. Packages which diff --git a/tests/ulib/inp/http/response.chunked b/tests/ulib/inp/http/response.chunked index 3425d6fd..16d63e48 100644 --- a/tests/ulib/inp/http/response.chunked +++ b/tests/ulib/inp/http/response.chunked @@ -17,9 +17,11 @@ Cache-control:no-cache chunked -27 +27; ignore-stuff-here

chunked

0 +some-footer: some-value +another-footer: another-value diff --git a/tests/ulib/json.test b/tests/ulib/json.test index 7a3c848f..6bc78b34 100755 --- a/tests/ulib/json.test +++ b/tests/ulib/json.test @@ -6,7 +6,7 @@ start_msg json -#UTRACE="0 100M -1" +#UTRACE="0 100M 0" #UOBJDUMP="0 100k 10" #USIMERR="error.sim" export UTRACE UOBJDUMP USIMERR diff --git a/tests/ulib/ok/certificate.ok b/tests/ulib/ok/certificate.ok index e0ad97d8..304a904e 100644 --- a/tests/ulib/ok/certificate.ok +++ b/tests/ulib/ok/certificate.ok @@ -49,7 +49,6 @@ 2 1 2094012269 -RSA-SHA1 100715153055Z 210627153055Z 0 @@ -106,7 +105,6 @@ RSA-SHA1 2 2 2747996067 -RSA-SHA1 100715153102Z 210627153102Z 0 diff --git a/tests/ulib/ok/pkcs10.ok b/tests/ulib/ok/pkcs10.ok index 86c37557..d32c8590 100644 --- a/tests/ulib/ok/pkcs10.ok +++ b/tests/ulib/ok/pkcs10.ok @@ -39,4 +39,3 @@ } /C=IT/ST=Firenze/L=Sesto Fiorentino/O=UniRel S.R.L./OU=TMail Project/CN=Alice/emailAddress=alice@unirel.com 0 -RSA-MD5 \ No newline at end of file diff --git a/tests/ulib/ssl_client_server.test b/tests/ulib/ssl_client_server.test index 8ca81ed6..8e0554a8 100755 --- a/tests/ulib/ssl_client_server.test +++ b/tests/ulib/ssl_client_server.test @@ -35,6 +35,7 @@ SERVER_KEY="CA/server.key" SERVER_CERT="CA/server.crt" #fi +#STRACE=$TRUSS start_prg_background ssl_server "$SERVER_CERT" "$SERVER_KEY" "caciucco" "$CACERT" "$CAPATH" 1 ../../src/ulib/net/server/plugin/.libs echo $SLEEP diff --git a/tests/ulib/test_certificate.cpp b/tests/ulib/test_certificate.cpp index 2757792f..ab9ca906 100644 --- a/tests/ulib/test_certificate.cpp +++ b/tests/ulib/test_certificate.cpp @@ -26,12 +26,9 @@ static void check(const UString& dati_cert, const UString& dati_ca) << c.getVersionNumber() << '\n' << c.getSerialNumber() << '\n' << c.hashCode() << '\n' - << c.getSignatureAlgorithm()<< '\n' << c.getNotBefore() << '\n' << c.getNotAfter() << '\n' << c.checkValidity() << '\n' - // << c.getSignature() << '\n' - // << c.getSignable() << '\n' << vec1 << '\n' << vec2 << '\n'; diff --git a/tests/ulib/test_crl.cpp b/tests/ulib/test_crl.cpp index fc685d7e..cc8df655 100644 --- a/tests/ulib/test_crl.cpp +++ b/tests/ulib/test_crl.cpp @@ -21,7 +21,6 @@ static void check(const UString& dati_crl, const UString& dati_ca) << c.getVersionNumber() << "\n" << c.getLastUpdate() << "\n" // << c.getRevokedSerials(revoked, 10) << "\n" - // << c.getSignature() << "\n" << c.getNextUpdate(); UString encoded = c.getEncoded("PEM"); diff --git a/tests/ulib/test_json.cpp b/tests/ulib/test_json.cpp index e3f83b5a..a130ffa4 100644 --- a/tests/ulib/test_json.cpp +++ b/tests/ulib/test_json.cpp @@ -104,8 +104,8 @@ static void testVector() U_TRACE(5, "testVector()") bool ok; + UValue json_vec; UVector y; - UValue json_vec(ARRAY_VALUE); UString result, vecJson = U_STRING_FROM_CONSTANT("[\"riga 1\",\"riga 2\",\"riga 3\",\"riga 4\"]"); ok = JSON_parse(vecJson, y); @@ -146,8 +146,8 @@ static void testMap() U_TRACE(5, "testMap()") bool ok; + UValue json_obj; UHashMap x; - UValue json_obj(OBJECT_VALUE); UString result, mapJson = U_STRING_FROM_CONSTANT("{\"key1\":\"riga 1\",\"key2\":\"riga 2\",\"key3\":\"riga 3\",\"key4\":\"riga 4\"}"); ok = JSON_parse(mapJson, x); @@ -189,7 +189,7 @@ static void testObject() bool ok; Request request; - UValue json_obj(OBJECT_VALUE); + UValue json_obj; UString result, reqJson = U_STRING_FROM_CONSTANT("{\"token\":\"A619828KAIJ6D3\",\"type\":\"localesData\",\"radius\":\"near\",\"location\":\"40.7831 N, 73.9712 W\"}"); ok = JSON_parse(reqJson, request); @@ -227,7 +227,7 @@ U_EXPORT main (int argc, char* argv[]) U_TRACE(5, "main(%d)", argc) #if defined(U_STDCPP_ENABLE) && defined(HAVE_CXX11) && defined(U_COMPILER_RANGE_FOR) - UValue json_vec(ARRAY_VALUE); + UValue json_vec; std::vector v = {0, 1, 2, 3, 4, 5}; UString vecJson = U_STRING_FROM_CONSTANT("[0,1,2,3,4,5]"); diff --git a/tests/ulib/test_pkcs10.cpp b/tests/ulib/test_pkcs10.cpp index 6c5f23f8..a930ae38 100644 --- a/tests/ulib/test_pkcs10.cpp +++ b/tests/ulib/test_pkcs10.cpp @@ -13,12 +13,9 @@ static void check(UString& dati, const char* file) UPKCS10 c(dati); - cout << c << "\n" - << c.getSubject() << "\n" - << c.getVersionNumber() << "\n" - // << c.getSignature() << "\n" - // << c.getSignable() << "\n" - << c.getSignatureAlgorithm(); + cout << c << "\n" + << c.getSubject() << "\n" + << c.getVersionNumber() << "\n"; UString encoded = c.getEncoded("PEM");