Check-in [bd8b53ced2]
Bounty program for improvements to Tcl and certain Tcl packages.
Overview
Comment:Try to find headers in a specific path and do not allow "mp_int"/"mp_digit" to conflict with other things
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | x-header-work
Files: files | file ages | folders
SHA3-256: bd8b53ced2d7762d7960e0a9c7a959cdd2fe8e994f1ab3bcc2005dc8c1163dd4
User & Date: rkeene on 2019-05-29 18:52:18
Other Links: branch diff | manifest | tags
Context
2019-05-29
18:52
Try to find headers in a specific path and do not allow "mp_int"/"mp_digit" to conflict with other things Leaf check-in: bd8b53ced2 user: rkeene tags: x-header-work
2019-04-25
16:51
TclTLS 1.7.18 check-in: fb6a7404da user: rkeene tags: tls-1-7, tls-1-7-18
Changes

Modified aclocal/tcltls_openssl.m4 from [c4132f494e] to [4ea3fa4aea].

    11     11   			AC_CHECK_FUNC($2,, [
    12     12   				proto_check='false'
    13     13   			])
    14     14   		], [
    15     15   			AC_LANG_PUSH(C)
    16     16   			AC_MSG_CHECKING([for $3 protocol support])
    17     17   			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
    18         -#include <openssl/ssl.h>
    19         -#include <openssl/opensslv.h>
           18  +#ifdef OPENSSL_HEADER_PREFIX
           19  +#  define OPENSSL_HEADER(header) <OPENSSL_HEADER_PREFIX/header>
           20  +#else
           21  +#  define OPENSSL_HEADER(header) <header>
           22  +#endif
           23  +#include OPENSSL_HEADER(openssl/ssl.h)
           24  +#include OPENSSL_HEADER(openssl/opensslv.h)
    20     25   #if (SSLEAY_VERSION_NUMBER >= 0x0907000L)
    21         -# include <openssl/conf.h>
           26  +# include OPENSSL_HEADER(openssl/conf.h)
    22     27   #endif
    23     28   			], [
    24     29   int x = $5;
    25     30   			])], [
    26     31   				AC_MSG_RESULT([yes])
    27     32   			], [
    28     33   				AC_MSG_RESULT([no])
................................................................................
    79     84   		if test -e "$openssldir/libssl.$SHOBJEXT"; then
    80     85   			TCLTLS_SSL_LIBS="-L$openssldir -lssl -lcrypto"
    81     86   			openssldir="`AS_DIRNAME(["$openssldir"])`"
    82     87   		else
    83     88   			TCLTLS_SSL_LIBS="-L$openssldir/lib -lssl -lcrypto"
    84     89   		fi
    85     90   		TCLTLS_SSL_CFLAGS="-I$openssldir/include"
           91  +		if test -n "$openssldir"; then
           92  +			AC_DEFINE_UNQUOTED(OPENSSL_HEADER_PREFIX, [$openssldir/include], [Path to OpenSSL headers])
           93  +		fi
    86     94   		TCLTLS_SSL_CPPFLAGS="-I$openssldir/include"
    87     95   	fi
    88     96   
    89     97   	pkgConfigExtraArgs=''
    90     98   	if test "$TCLEXT_BUILD" = "static" -o "$TCLEXT_TLS_STATIC_SSL" = 'yes'; then
    91     99   		pkgConfigExtraArgs='--static'
    92    100   	fi
................................................................................
   110    118   		TCLTLS_SSL_LIBS="`"${PKGCONFIG}" openssl --libs $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
   111    119   	fi
   112    120   	if test -z "$TCLTLS_SSL_CFLAGS"; then
   113    121   		TCLTLS_SSL_CFLAGS="`"${PKGCONFIG}" openssl --cflags-only-other $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
   114    122   	fi
   115    123   	if test -z "$TCLTLS_SSL_CPPFLAGS"; then
   116    124   		TCLTLS_SSL_CPPFLAGS="`"${PKGCONFIG}" openssl --cflags-only-I $pkgConfigExtraArgs`" || AC_MSG_ERROR([Unable to get OpenSSL Configuration])
          125  +		opensslincdir="$(echo "${TCLTLS_SSL_CPPFLAGS}" | sed '[email protected]^.*[email protected]@')"
          126  +		if test -n "$opensslincdir"; then
          127  +			AC_DEFINE_UNQUOTED(OPENSSL_HEADER_PREFIX, [$opensslincdir], [Path to OpenSSL headers])
          128  +		fi
   117    129   	fi
   118    130   	PKG_CONFIG_PATH="${PKG_CONFIG_PATH_SAVE}"
   119    131   
   120    132   	if test "$TCLEXT_BUILD" = "static"; then
   121    133   		dnl If we are doing a static build, save the linker flags for other programs to consume
   122    134   		rm -f tcltls.a.linkadd
   123    135   		AS_ECHO(["$TCLTLS_SSL_LIBS"]) > tcltls.a.linkadd
................................................................................
   162    174   	CFLAGS="${TCLTLS_SSL_CFLAGS} ${SAVE_CFLAGS} ${TCLTLS_SSL_CFLAGS}"
   163    175   	CPPFLAGS="${TCLTLS_SSL_CPPFLAGS} ${SAVE_CPPFLAGS} ${TCLTLS_SSL_CPPFLAGS}"
   164    176   
   165    177   	dnl Verify that basic functionality is there
   166    178   	AC_LANG_PUSH(C)
   167    179   	AC_MSG_CHECKING([if a basic OpenSSL program works])
   168    180   	AC_LINK_IFELSE([AC_LANG_PROGRAM([
   169         -#include <openssl/ssl.h>
   170         -#include <openssl/opensslv.h>
          181  +#ifdef OPENSSL_HEADER_PREFIX
          182  +#  define OPENSSL_HEADER(header) <OPENSSL_HEADER_PREFIX/header>
          183  +#else
          184  +#  define OPENSSL_HEADER(header) <header>
          185  +#endif
          186  +#include OPENSSL_HEADER(openssl/ssl.h)
          187  +#include OPENSSL_HEADER(openssl/opensslv.h)
   171    188   #if (SSLEAY_VERSION_NUMBER >= 0x0907000L)
   172         -# include <openssl/conf.h>
          189  +# include OPENSSL_HEADER(openssl/conf.h)
   173    190   #endif
   174    191   		], [
   175    192     SSL_library_init();
   176    193     SSL_load_error_strings();
   177    194   		])], [
   178    195   		AC_MSG_RESULT([yes])
   179    196   	], [
................................................................................
   190    207   	TCLTLS_SSL_OPENSSL_CHECK_PROTO_VER([tcltls_ssl_tls1_2], [TLSv1_2_method], [tlsv1.2], [NO_TLS1_2])
   191    208   	TCLTLS_SSL_OPENSSL_CHECK_PROTO_VER([tcltls_ssl_tls1_3], [], [tlsv1.3], [NO_TLS1_3], [SSL_OP_NO_TLSv1_3])
   192    209   
   193    210   	AC_CACHE_VAL([tcltls_cv_func_tlsext_hostname], [
   194    211   		AC_LANG_PUSH(C)
   195    212   		AC_MSG_CHECKING([for SSL_set_tlsext_host_name])
   196    213   		AC_LINK_IFELSE([AC_LANG_PROGRAM([
   197         -#include <openssl/ssl.h>
          214  +#ifdef OPENSSL_HEADER_PREFIX
          215  +#  define OPENSSL_HEADER(header) <OPENSSL_HEADER_PREFIX/header>
          216  +#else
          217  +#  define OPENSSL_HEADER(header) <header>
          218  +#endif
          219  +#include OPENSSL_HEADER(openssl/ssl.h)
   198    220   #if (SSLEAY_VERSION_NUMBER >= 0x0907000L)
   199         -# include <openssl/conf.h>
          221  +# include OPENSSL_HEADER(openssl/conf.h)
   200    222   #endif
   201    223   			], [
   202    224     (void)SSL_set_tlsext_host_name((void *) 0, (void *) 0);
   203    225   			])], [
   204    226   			AC_MSG_RESULT([yes])
   205    227   			tcltls_cv_func_tlsext_hostname='yes'
   206    228   		], [

Modified tls.c from [c565bf20f1] to [391c72843c].

   104    104   
   105    105   /*
   106    106    * Thread-Safe TLS Code
   107    107    */
   108    108   
   109    109   #ifdef TCL_THREADS
   110    110   #define OPENSSL_THREAD_DEFINES
   111         -#include <openssl/opensslconf.h>
          111  +#include OPENSSL_HEADER(openssl/opensslconf.h)
   112    112   
   113    113   #ifdef OPENSSL_THREADS
   114         -#include <openssl/crypto.h>
          114  +#include OPENSSL_HEADER(openssl/crypto.h)
   115    115   
   116    116   /*
   117    117    * Threaded operation requires locking callbacks
   118    118    * Based from /crypto/cryptlib.c of OpenSSL and NSOpenSSL.
   119    119    */
   120    120   
   121    121   static Tcl_Mutex *locks = NULL;

Modified tls.h from [5e9dbae35a] to [32e35217c8].

    14     14    *	tclSSL (Colin McCormack, Shared Technology)
    15     15    *	SSLtcl (Peter Antman)
    16     16    *
    17     17    */
    18     18   #ifndef _TLS_H
    19     19   #define _TLS_H
    20     20   
           21  +#define mp_digit __TCL_MP_DIGIT
           22  +#define mp_int   __TCL_MP_INT
    21     23   #include <tcl.h>
           24  +#undef mp_digit
           25  +#undef mp_int
    22     26   
    23     27   /*
    24     28    * Initialization routines -- our entire public C API.
    25     29    */
    26     30   int Tls_Init(Tcl_Interp *interp);
    27     31   int Tls_SafeInit(Tcl_Interp *interp);
    28     32   
    29     33   #endif /* _TLS_H */

Modified tlsInt.h from [b78d815874] to [50b6f39a60].

    18     18   #ifndef _TLSINT_H
    19     19   #define _TLSINT_H
    20     20   
    21     21   #include "tls.h"
    22     22   #include <errno.h>
    23     23   #include <string.h>
    24     24   #include <stdint.h>
           25  +
           26  +#ifdef OPENSSL_HEADER_PREFIX
           27  +#  define OPENSSL_HEADER(header) <OPENSSL_HEADER_PREFIX/header>
           28  +#else
           29  +#  define OPENSSL_HEADER(header) <header>
           30  +#endif
    25     31   
    26     32   #ifdef __WIN32__
    27     33   #define WIN32_LEAN_AND_MEAN
    28     34   #include <windows.h>
    29     35   #include <wincrypt.h> /* OpenSSL needs this on Windows */
    30     36   #endif
    31     37   
................................................................................
    41     47   #  define NO_RC5
    42     48   #  define NO_RSA
    43     49   #  ifndef NO_SSL2
    44     50   #    define NO_SSL2
    45     51   #  endif
    46     52   #endif
    47     53   
    48         -#include <openssl/ssl.h>
    49         -#include <openssl/err.h>
    50         -#include <openssl/rand.h>
    51         -#include <openssl/opensslv.h>
           54  +#include OPENSSL_HEADER(openssl/ssl.h)
           55  +#include OPENSSL_HEADER(openssl/err.h)
           56  +#include OPENSSL_HEADER(openssl/rand.h)
           57  +#include OPENSSL_HEADER(openssl/opensslv.h)
    52     58   
    53     59   /*
    54     60    * Determine if we should use the pre-OpenSSL 1.1.0 API
    55     61    */
    56     62   #undef TCLTLS_OPENSSL_PRE_1_1
    57     63   #if (defined(LIBRESSL_VERSION_NUMBER)) || OPENSSL_VERSION_NUMBER < 0x10100000L
    58     64   #  define TCLTLS_OPENSSL_PRE_1_1_API 1