Module Name:    src
Committed By:   christos
Date:           Tue Feb  6 01:57:24 UTC 2018

Modified Files:
        src/external/bsd/openldap/dist/build: mkversion
        src/external/bsd/openldap/dist/clients/tools: common.c
        src/external/bsd/openldap/dist/include: Makefile.in ldap_queue.h
            portable.hin
        src/external/bsd/openldap/dist/libraries/libldap: os-ip.c os-local.c
            tls_o.c
        src/external/bsd/openldap/dist/libraries/liblutil: detach.c md5.c
            passwd.c
        src/external/bsd/openldap/dist/libraries/librewrite: session.c
        src/external/bsd/openldap/dist/servers/slapd: filter.c
        src/external/bsd/openldap/dist/servers/slapd/overlays: deref.c
Removed Files:
        src/external/bsd/openldap/dist: libtool

Log Message:
merge conflicts


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/openldap/dist/libtool
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/openldap/dist/build/mkversion
cvs rdiff -u -r1.6 -r1.7 \
    src/external/bsd/openldap/dist/clients/tools/common.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/openldap/dist/include/Makefile.in \
    src/external/bsd/openldap/dist/include/portable.hin
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/openldap/dist/include/ldap_queue.h
cvs rdiff -u -r1.7 -r1.8 \
    src/external/bsd/openldap/dist/libraries/libldap/os-ip.c
cvs rdiff -u -r1.8 -r1.9 \
    src/external/bsd/openldap/dist/libraries/libldap/os-local.c
cvs rdiff -u -r1.5 -r1.6 \
    src/external/bsd/openldap/dist/libraries/libldap/tls_o.c
cvs rdiff -u -r1.4 -r1.5 \
    src/external/bsd/openldap/dist/libraries/liblutil/detach.c \
    src/external/bsd/openldap/dist/libraries/liblutil/md5.c
cvs rdiff -u -r1.5 -r1.6 \
    src/external/bsd/openldap/dist/libraries/liblutil/passwd.c
cvs rdiff -u -r1.3 -r1.4 \
    src/external/bsd/openldap/dist/libraries/librewrite/session.c
cvs rdiff -u -r1.4 -r1.5 \
    src/external/bsd/openldap/dist/servers/slapd/filter.c
cvs rdiff -u -r1.3 -r1.4 \
    src/external/bsd/openldap/dist/servers/slapd/overlays/deref.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/openldap/dist/build/mkversion
diff -u src/external/bsd/openldap/dist/build/mkversion:1.6 src/external/bsd/openldap/dist/build/mkversion:1.7
--- src/external/bsd/openldap/dist/build/mkversion:1.6	Wed Feb  8 20:53:50 2017
+++ src/external/bsd/openldap/dist/build/mkversion	Mon Feb  5 20:57:23 2018
@@ -3,7 +3,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2016 The OpenLDAP Foundation.
+## Copyright 1998-2017 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -54,7 +54,7 @@ APPLICATION=$1
 cat << __EOF__
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@ cat << __EOF__
  */
 
 static const char copyright[] =
-"Copyright 1998-2016 The OpenLDAP Foundation.  All rights reserved.\n"
+"Copyright 1998-2017 The OpenLDAP Foundation.  All rights reserved.\n"
 "COPYING RESTRICTIONS APPLY\n";
 
 $static $const char $SYMBOL[] =

Index: src/external/bsd/openldap/dist/clients/tools/common.c
diff -u src/external/bsd/openldap/dist/clients/tools/common.c:1.6 src/external/bsd/openldap/dist/clients/tools/common.c:1.7
--- src/external/bsd/openldap/dist/clients/tools/common.c:1.6	Wed Feb  8 20:53:50 2017
+++ src/external/bsd/openldap/dist/clients/tools/common.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: common.c,v 1.6 2017/02/09 01:53:50 christos Exp $	*/
+/*	$NetBSD: common.c,v 1.7 2018/02/06 01:57:23 christos Exp $	*/
 
 /* common.c - common routines for the ldap client tools */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * Portions Copyright 2003 Kurt D. Zeilenga.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: common.c,v 1.6 2017/02/09 01:53:50 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.7 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 

Index: src/external/bsd/openldap/dist/include/Makefile.in
diff -u src/external/bsd/openldap/dist/include/Makefile.in:1.6 src/external/bsd/openldap/dist/include/Makefile.in:1.7
--- src/external/bsd/openldap/dist/include/Makefile.in:1.6	Wed Feb  8 20:53:50 2017
+++ src/external/bsd/openldap/dist/include/Makefile.in	Mon Feb  5 20:57:23 2018
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2016 The OpenLDAP Foundation.
+## Copyright 1998-2017 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
Index: src/external/bsd/openldap/dist/include/portable.hin
diff -u src/external/bsd/openldap/dist/include/portable.hin:1.6 src/external/bsd/openldap/dist/include/portable.hin:1.7
--- src/external/bsd/openldap/dist/include/portable.hin:1.6	Wed Feb  8 20:53:50 2017
+++ src/external/bsd/openldap/dist/include/portable.hin	Mon Feb  5 20:57:23 2018
@@ -4,7 +4,7 @@
 /* begin of portable.h.pre */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation
+ * Copyright 1998-2017 The OpenLDAP Foundation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Index: src/external/bsd/openldap/dist/include/ldap_queue.h
diff -u src/external/bsd/openldap/dist/include/ldap_queue.h:1.4 src/external/bsd/openldap/dist/include/ldap_queue.h:1.5
--- src/external/bsd/openldap/dist/include/ldap_queue.h:1.4	Wed Feb  8 20:53:50 2017
+++ src/external/bsd/openldap/dist/include/ldap_queue.h	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: ldap_queue.h,v 1.4 2017/02/09 01:53:50 christos Exp $	*/
+/*	$NetBSD: ldap_queue.h,v 1.5 2018/02/06 01:57:23 christos Exp $	*/
 
 /* ldap_queue.h -- queue macros */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2016 The OpenLDAP Foundation.
+ * Copyright 2001-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -227,7 +227,7 @@ struct {								\
 } while (0)
 
 #define LDAP_STAILQ_ENTRY_INIT(var, field) {				\
-	(entry)->field.stqe_next = NULL;				\
+	(var)->field.stqe_next = NULL;					\
 }
 
 #define LDAP_STAILQ_FIRST(head)	((head)->stqh_first)
@@ -386,26 +386,20 @@ struct {								\
 #define LDAP_TAILQ_FOREACH(var, head, field)				\
 	for (var = LDAP_TAILQ_FIRST(head); var; var = LDAP_TAILQ_NEXT(var, field))
 
-#define LDAP_TAILQ_FOREACH_REVERSE(var, head, type, field)		\
-	for ((var) = LDAP_TAILQ_LAST((head), type, field);		\
+#define LDAP_TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = LDAP_TAILQ_LAST((head), headname);			\
 	     (var);							\
-	     (var) = LDAP_TAILQ_PREV((var), head, type, field))
+	     (var) = LDAP_TAILQ_PREV((var), headname, field))
 
 #define	LDAP_TAILQ_FIRST(head) ((head)->tqh_first)
 
-#define LDAP_TAILQ_LAST(head, type, field)				\
-	(LDAP_TAILQ_EMPTY(head) ?					\
-	 	NULL :							\
-		((struct type *)					\
-		((char *)((head)->tqh_last) - offsetof(struct type, field))))
+#define	LDAP_TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
 
 #define	LDAP_TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
 
-#define LDAP_TAILQ_PREV(elm, head, type, field) 			\
-	((struct type *)((elm)->field.tqe_prev) == LDAP_TAILQ_FIRST(head) ? \
-	NULL :								\
-	((struct type *)						\
-	((char *)((elm)->field.tqe_prev) - offsetof(struct type, field))))
+#define LDAP_TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
 
 #define	LDAP_TAILQ_INIT(head) do {					\
 	(head)->tqh_first = NULL;					\

Index: src/external/bsd/openldap/dist/libraries/libldap/os-ip.c
diff -u src/external/bsd/openldap/dist/libraries/libldap/os-ip.c:1.7 src/external/bsd/openldap/dist/libraries/libldap/os-ip.c:1.8
--- src/external/bsd/openldap/dist/libraries/libldap/os-ip.c:1.7	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/libraries/libldap/os-ip.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: os-ip.c,v 1.7 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: os-ip.c,v 1.8 2018/02/06 01:57:23 christos Exp $	*/
 
 /* os-ip.c -- platform-specific TCP & UDP related code */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * Portions Copyright 1999 Lars Uffmann.
  * All rights reserved.
  *
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: os-ip.c,v 1.7 2017/02/09 01:53:51 christos Exp $");
+__RCSID("$NetBSD: os-ip.c,v 1.8 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 

Index: src/external/bsd/openldap/dist/libraries/libldap/os-local.c
diff -u src/external/bsd/openldap/dist/libraries/libldap/os-local.c:1.8 src/external/bsd/openldap/dist/libraries/libldap/os-local.c:1.9
--- src/external/bsd/openldap/dist/libraries/libldap/os-local.c:1.8	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/libraries/libldap/os-local.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: os-local.c,v 1.8 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: os-local.c,v 1.9 2018/02/06 01:57:23 christos Exp $	*/
 
 /* os-local.c -- platform-specific domain socket code */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: os-local.c,v 1.8 2017/02/09 01:53:51 christos Exp $");
+__RCSID("$NetBSD: os-local.c,v 1.9 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 

Index: src/external/bsd/openldap/dist/libraries/libldap/tls_o.c
diff -u src/external/bsd/openldap/dist/libraries/libldap/tls_o.c:1.5 src/external/bsd/openldap/dist/libraries/libldap/tls_o.c:1.6
--- src/external/bsd/openldap/dist/libraries/libldap/tls_o.c:1.5	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/libraries/libldap/tls_o.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: tls_o.c,v 1.5 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: tls_o.c,v 1.6 2018/02/06 01:57:23 christos Exp $	*/
 
 /* tls_o.c - Handle tls/ssl using OpenSSL */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2008-2016 The OpenLDAP Foundation.
+ * Copyright 2008-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tls_o.c,v 1.5 2017/02/09 01:53:51 christos Exp $");
+__RCSID("$NetBSD: tls_o.c,v 1.6 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 
@@ -52,6 +52,10 @@ __RCSID("$NetBSD: tls_o.c,v 1.5 2017/02/
 #include <ssl.h>
 #endif
 
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+#define ASN1_STRING_data(x)	ASN1_STRING_get0_data(x)
+#endif
+
 typedef SSL_CTX tlso_ctx;
 typedef SSL tlso_session;
 
@@ -62,26 +66,18 @@ static void tlso_report_error( void );
 static void tlso_info_cb( const SSL *ssl, int where, int ret );
 static int tlso_verify_cb( int ok, X509_STORE_CTX *ctx );
 static int tlso_verify_ok( int ok, X509_STORE_CTX *ctx );
-static RSA * tlso_tmp_rsa_cb( SSL *ssl, int is_export, int key_length );
-
-static DH * tlso_tmp_dh_cb( SSL *ssl, int is_export, int key_length );
-
-typedef struct dhplist {
-	struct dhplist *next;
-	int keylength;
-	DH *param;
-} dhplist;
-
-static dhplist *tlso_dhparams;
-
 static int tlso_seed_PRNG( const char *randfile );
+#if OPENSSL_VERSION_NUMBER < 0x10100000
+/*
+ * OpenSSL 1.1 API and later has new locking code
+*/
+static RSA * tlso_tmp_rsa_cb( SSL *ssl, int is_export, int key_length );
 
 #ifdef LDAP_R_COMPILE
 /*
  * provide mutexes for the OpenSSL library.
  */
 static ldap_pvt_thread_mutex_t	tlso_mutexes[CRYPTO_NUM_LOCKS];
-static ldap_pvt_thread_mutex_t	tlso_dh_mutex;
 
 static void tlso_locking_cb( int mode, int type, const char *file, int line )
 {
@@ -112,11 +108,15 @@ static void tlso_thr_init( void )
 	for( i=0; i< CRYPTO_NUM_LOCKS ; i++ ) {
 		ldap_pvt_thread_mutex_init( &tlso_mutexes[i] );
 	}
-	ldap_pvt_thread_mutex_init( &tlso_dh_mutex );
 	CRYPTO_set_locking_callback( tlso_locking_cb );
 	CRYPTO_set_id_callback( tlso_thread_self );
 }
 #endif /* LDAP_R_COMPILE */
+#else
+#ifdef LDAP_R_COMPILE
+static void tlso_thr_init( void ) {}
+#endif
+#endif /* OpenSSL 1.1 */
 
 static STACK_OF(X509_NAME) *
 tlso_ca_list( char * bundle, char * dir )
@@ -162,9 +162,13 @@ tlso_init( void )
 	(void) tlso_seed_PRNG( lo->ldo_tls_randfile );
 #endif
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000
 	SSL_load_error_strings();
 	SSL_library_init();
 	OpenSSL_add_all_digests();
+#else
+	OPENSSL_init_ssl(0, NULL);
+#endif
 
 	/* FIXME: mod_ssl does this */
 	X509V3_add_standard_extensions();
@@ -180,9 +184,15 @@ tlso_destroy( void )
 {
 	struct ldapoptions *lo = LDAP_INT_GLOBAL_OPT();   
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000
 	EVP_cleanup();
+#if OPENSSL_VERSION_NUMBER < 0x10000000
 	ERR_remove_state(0);
+#else
+	ERR_remove_thread_state(NULL);
+#endif
 	ERR_free_strings();
+#endif
 
 	if ( lo->ldo_tls_randfile ) {
 		LDAP_FREE( lo->ldo_tls_randfile );
@@ -200,7 +210,10 @@ static void
 tlso_ctx_ref( tls_ctx *ctx )
 {
 	tlso_ctx *c = (tlso_ctx *)ctx;
-	CRYPTO_add( &c->references, 1, CRYPTO_LOCK_SSL_CTX );
+#if OPENSSL_VERSION_NUMBER < 0x10100000
+#define	SSL_CTX_up_ref(ctx)	CRYPTO_add( &(ctx->references), 1, CRYPTO_LOCK_SSL_CTX )
+#endif
+	SSL_CTX_up_ref( c );
 }
 
 static void
@@ -258,10 +271,16 @@ tlso_ctx_init( struct ldapoptions *lo, s
 		return -1;
 	}
 
-	if (lo->ldo_tls_cacertfile != NULL || lo->ldo_tls_cacertdir != NULL) {
+	if ( lo->ldo_tls_cacertfile == NULL && lo->ldo_tls_cacertdir == NULL ) {
+		if ( !SSL_CTX_set_default_verify_paths( ctx ) ) {
+			Debug( LDAP_DEBUG_ANY, "TLS: "
+				"could not use default certificate paths", 0, 0, 0 );
+			tlso_report_error();
+			return -1;
+		}
+	} else {
 		if ( !SSL_CTX_load_verify_locations( ctx,
-				lt->lt_cacertfile, lt->lt_cacertdir ) ||
-			!SSL_CTX_set_default_verify_paths( ctx ) )
+				lt->lt_cacertfile, lt->lt_cacertdir ) )
 		{
 			Debug( LDAP_DEBUG_ANY, "TLS: "
 				"could not load verify locations (file:`%s',dir:`%s').\n",
@@ -316,7 +335,7 @@ tlso_ctx_init( struct ldapoptions *lo, s
 	if ( lo->ldo_tls_dhfile ) {
 		DH *dh = NULL;
 		BIO *bio;
-		dhplist *p;
+		SSL_CTX_set_options( ctx, SSL_OP_SINGLE_DH_USE );
 
 		if (( bio=BIO_new_file( lt->lt_dhfile,"r" )) == NULL ) {
 			Debug( LDAP_DEBUG_ANY,
@@ -325,16 +344,16 @@ tlso_ctx_init( struct ldapoptions *lo, s
 			tlso_report_error();
 			return -1;
 		}
-		while (( dh=PEM_read_bio_DHparams( bio, NULL, NULL, NULL ))) {
-			p = LDAP_MALLOC( sizeof(dhplist) );
-			if ( p != NULL ) {
-				p->keylength = DH_size( dh ) * 8;
-				p->param = dh;
-				p->next = tlso_dhparams;
-				tlso_dhparams = p;
-			}
+		if (!( dh=PEM_read_bio_DHparams( bio, NULL, NULL, NULL ))) {
+			Debug( LDAP_DEBUG_ANY,
+				"TLS: could not read DH parameters file `%s'.\n",
+				lo->ldo_tls_dhfile,0,0);
+			tlso_report_error();
+			BIO_free( bio );
+			return -1;
 		}
 		BIO_free( bio );
+		SSL_CTX_set_tmp_dh( ctx, dh );
 	}
 
 	if ( tlso_opt_trace ) {
@@ -353,10 +372,9 @@ tlso_ctx_init( struct ldapoptions *lo, s
 	SSL_CTX_set_verify( ctx, i,
 		lo->ldo_tls_require_cert == LDAP_OPT_X_TLS_ALLOW ?
 		tlso_verify_ok : tlso_verify_cb );
+#if OPENSSL_VERSION_NUMBER < 0x10100000
 	SSL_CTX_set_tmp_rsa_callback( ctx, tlso_tmp_rsa_cb );
-	if ( lo->ldo_tls_dhfile ) {
-		SSL_CTX_set_tmp_dh_callback( ctx, tlso_tmp_dh_cb );
-	}
+#endif
 #ifdef HAVE_OPENSSL_CRL
 	if ( lo->ldo_tls_crlcheck ) {
 		X509_STORE *x509_s = SSL_CTX_get_cert_store( ctx );
@@ -451,8 +469,17 @@ tlso_session_my_dn( tls_session *sess, s
 	if (!x) return LDAP_INVALID_CREDENTIALS;
 	
 	xn = X509_get_subject_name(x);
+#if OPENSSL_VERSION_NUMBER < 0x10100000
 	der_dn->bv_len = i2d_X509_NAME( xn, NULL );
 	der_dn->bv_val = xn->bytes->data;
+#else
+	{
+		size_t len = 0;
+		der_dn->bv_val = NULL;
+		X509_NAME_get0_der( xn, (const unsigned char **)&der_dn->bv_val, &len );
+		der_dn->bv_len = len;
+	}
+#endif
 	/* Don't X509_free, the session is still using it */
 	return 0;
 }
@@ -478,8 +505,17 @@ tlso_session_peer_dn( tls_session *sess,
 		return LDAP_INVALID_CREDENTIALS;
 
 	xn = X509_get_subject_name(x);
+#if OPENSSL_VERSION_NUMBER < 0x10100000
 	der_dn->bv_len = i2d_X509_NAME( xn, NULL );
 	der_dn->bv_val = xn->bytes->data;
+#else
+	{
+		size_t len = 0;
+		der_dn->bv_val = NULL;
+		X509_NAME_get0_der( xn, (const unsigned char **)&der_dn->bv_val, &len );
+		der_dn->bv_len = len;
+	}
+#endif
 	X509_free(x);
 	return 0;
 }
@@ -619,7 +655,7 @@ tlso_session_chkhost( LDAP *ld, tls_sess
 		navas = X509_NAME_entry_count( xn );
 		for ( i=navas-1; i>=0; i-- ) {
 			ne = X509_NAME_get_entry( xn, i );
-			if ( !OBJ_cmp( ne->object, obj )) {
+			if ( !OBJ_cmp( X509_NAME_ENTRY_get_object(ne), obj )) {
 				cn = X509_NAME_ENTRY_get_data( ne );
 				break;
 			}
@@ -690,12 +726,17 @@ struct tls_data {
 	Sockbuf_IO_Desc		*sbiod;
 };
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000
+#define BIO_set_init(b, x)	b->init = x
+#define BIO_set_data(b, x)	b->ptr = x
+#define BIO_clear_flags(b, x)	b->flags &= ~(x)
+#define BIO_get_data(b)	b->ptr
+#endif
 static int
 tlso_bio_create( BIO *b ) {
-	b->init = 1;
-	b->num = 0;
-	b->ptr = NULL;
-	b->flags = 0;
+	BIO_set_init( b, 1 );
+	BIO_set_data( b, NULL );
+	BIO_clear_flags( b, ~0 );
 	return 1;
 }
 
@@ -704,9 +745,9 @@ tlso_bio_destroy( BIO *b )
 {
 	if ( b == NULL ) return 0;
 
-	b->ptr = NULL;		/* sb_tls_remove() will free it */
-	b->init = 0;
-	b->flags = 0;
+	BIO_set_data( b, NULL );		/* sb_tls_remove() will free it */
+	BIO_set_init( b, 0 );
+	BIO_clear_flags( b, ~0 );
 	return 1;
 }
 
@@ -718,7 +759,7 @@ tlso_bio_read( BIO *b, char *buf, int le
 		
 	if ( buf == NULL || len <= 0 ) return 0;
 
-	p = (struct tls_data *)b->ptr;
+	p = (struct tls_data *)BIO_get_data(b);
 
 	if ( p == NULL || p->sbiod == NULL ) {
 		return 0;
@@ -745,7 +786,7 @@ tlso_bio_write( BIO *b, const char *buf,
 	
 	if ( buf == NULL || len <= 0 ) return 0;
 	
-	p = (struct tls_data *)b->ptr;
+	p = (struct tls_data *)BIO_get_data(b);
 
 	if ( p == NULL || p->sbiod == NULL ) {
 		return 0;
@@ -785,7 +826,22 @@ tlso_bio_puts( BIO *b, const char *str )
 {
 	return tlso_bio_write( b, str, strlen( str ) );
 }
-	
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+struct bio_method_st {
+    int type;
+    const char *name;
+    int (*bwrite) (BIO *, const char *, int);
+    int (*bread) (BIO *, char *, int);
+    int (*bputs) (BIO *, const char *);
+    int (*bgets) (BIO *, char *, int);
+    long (*ctrl) (BIO *, int, long, void *);
+    int (*create) (BIO *);
+    int (*destroy) (BIO *);
+    long (*callback_ctrl) (BIO *, int, bio_info_cb *);
+};
+#endif
+
 static BIO_METHOD tlso_bio_method =
 {
 	( 100 | 0x400 ),		/* it's a source/sink BIO */
@@ -815,7 +871,7 @@ tlso_sb_setup( Sockbuf_IO_Desc *sbiod, v
 	p->session = arg;
 	p->sbiod = sbiod;
 	bio = BIO_new( &tlso_bio_method );
-	bio->ptr = (void *)p;
+	BIO_set_data( bio, p );
 	SSL_set_bio( p->session, bio, bio );
 	sbiod->sbiod_pvt = p;
 	return 0;
@@ -1045,9 +1101,9 @@ tlso_verify_cb( int ok, X509_STORE_CTX *
 			certerr, 0, 0 );
 	}
 	if ( sname )
-		CRYPTO_free ( sname );
+		OPENSSL_free ( sname );
 	if ( iname )
-		CRYPTO_free ( iname );
+		OPENSSL_free ( iname );
 #ifdef HAVE_EBCDIC
 	if ( certerr ) LDAP_FREE( certerr );
 #endif
@@ -1087,6 +1143,7 @@ tlso_report_error( void )
 	}
 }
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000
 static RSA *
 tlso_tmp_rsa_cb( SSL *ssl, int is_export, int key_length )
 {
@@ -1117,6 +1174,7 @@ tlso_tmp_rsa_cb( SSL *ssl, int is_export
 	}
 	return tmp_rsa;
 }
+#endif /* OPENSSL_VERSION_NUMBER < 1.1 */
 
 static int
 tlso_seed_PRNG( const char *randfile )
@@ -1165,108 +1223,6 @@ tlso_seed_PRNG( const char *randfile )
 	return 0;
 }
 
-struct dhinfo {
-	int keylength;
-	const char *pem;
-	size_t size;
-};
-
-
-/* From the OpenSSL 0.9.7 distro */
-static const char tlso_dhpem512[] =
-"-----BEGIN DH PARAMETERS-----\n\
-MEYCQQDaWDwW2YUiidDkr3VvTMqS3UvlM7gE+w/tlO+cikQD7VdGUNNpmdsp13Yn\n\
-a6LT1BLiGPTdHghM9tgAPnxHdOgzAgEC\n\
------END DH PARAMETERS-----\n";
-
-static const char tlso_dhpem1024[] =
-"-----BEGIN DH PARAMETERS-----\n\
-MIGHAoGBAJf2QmHKtQXdKCjhPx1ottPb0PMTBH9A6FbaWMsTuKG/K3g6TG1Z1fkq\n\
-/Gz/PWk/eLI9TzFgqVAuPvr3q14a1aZeVUMTgo2oO5/y2UHe6VaJ+trqCTat3xlx\n\
-/mNbIK9HA2RgPC3gWfVLZQrY+gz3ASHHR5nXWHEyvpuZm7m3h+irAgEC\n\
------END DH PARAMETERS-----\n";
-
-static const char tlso_dhpem2048[] =
-"-----BEGIN DH PARAMETERS-----\n\
-MIIBCAKCAQEA7ZKJNYJFVcs7+6J2WmkEYb8h86tT0s0h2v94GRFS8Q7B4lW9aG9o\n\
-AFO5Imov5Jo0H2XMWTKKvbHbSe3fpxJmw/0hBHAY8H/W91hRGXKCeyKpNBgdL8sh\n\
-z22SrkO2qCnHJ6PLAMXy5fsKpFmFor2tRfCzrfnggTXu2YOzzK7q62bmqVdmufEo\n\
-pT8igNcLpvZxk5uBDvhakObMym9mX3rAEBoe8PwttggMYiiw7NuJKO4MqD1llGkW\n\
-aVM8U2ATsCun1IKHrRxynkE1/MJ86VHeYYX8GZt2YA8z+GuzylIOKcMH6JAWzMwA\n\
-Gbatw6QwizOhr9iMjZ0B26TE3X8LvW84wwIBAg==\n\
------END DH PARAMETERS-----\n";
-
-static const char tlso_dhpem4096[] =
-"-----BEGIN DH PARAMETERS-----\n\
-MIICCAKCAgEA/urRnb6vkPYc/KEGXWnbCIOaKitq7ySIq9dTH7s+Ri59zs77zty7\n\
-vfVlSe6VFTBWgYjD2XKUFmtqq6CqXMhVX5ElUDoYDpAyTH85xqNFLzFC7nKrff/H\n\
-TFKNttp22cZE9V0IPpzedPfnQkE7aUdmF9JnDyv21Z/818O93u1B4r0szdnmEvEF\n\
-bKuIxEHX+bp0ZR7RqE1AeifXGJX3d6tsd2PMAObxwwsv55RGkn50vHO4QxtTARr1\n\
-rRUV5j3B3oPMgC7Offxx+98Xn45B1/G0Prp11anDsR1PGwtaCYipqsvMwQUSJtyE\n\
-EOQWk+yFkeMe4vWv367eEi0Sd/wnC+TSXBE3pYvpYerJ8n1MceI5GQTdarJ77OW9\n\
-bGTHmxRsLSCM1jpLdPja5jjb4siAa6EHc4qN9c/iFKS3PQPJEnX7pXKBRs5f7AF3\n\
-W3RIGt+G9IVNZfXaS7Z/iCpgzgvKCs0VeqN38QsJGtC1aIkwOeyjPNy2G6jJ4yqH\n\
-ovXYt/0mc00vCWeSNS1wren0pR2EiLxX0ypjjgsU1mk/Z3b/+zVf7fZSIB+nDLjb\n\
-NPtUlJCVGnAeBK1J1nG3TQicqowOXoM6ISkdaXj5GPJdXHab2+S7cqhKGv5qC7rR\n\
-jT6sx7RUr0CNTxzLI7muV2/a4tGmj0PSdXQdsZ7tw7gbXlaWT1+MM2MCAQI=\n\
------END DH PARAMETERS-----\n";
-
-static const struct dhinfo tlso_dhpem[] = {
-	{ 512, tlso_dhpem512, sizeof(tlso_dhpem512) },
-	{ 1024, tlso_dhpem1024, sizeof(tlso_dhpem1024) },
-	{ 2048, tlso_dhpem2048, sizeof(tlso_dhpem2048) },
-	{ 4096, tlso_dhpem4096, sizeof(tlso_dhpem4096) },
-	{ 0, NULL, 0 }
-};
-
-static DH *
-tlso_tmp_dh_cb( SSL *ssl, int is_export, int key_length )
-{
-	struct dhplist *p = NULL;
-	BIO *b = NULL;
-	DH *dh = NULL;
-	int i;
-
-	/* Do we have params of this length already? */
-	LDAP_MUTEX_LOCK( &tlso_dh_mutex );
-	for ( p = tlso_dhparams; p; p=p->next ) {
-		if ( p->keylength == key_length ) {
-			LDAP_MUTEX_UNLOCK( &tlso_dh_mutex );
-			return p->param;
-		}
-	}
-
-	/* No - check for hardcoded params */
-
-	for (i=0; tlso_dhpem[i].keylength; i++) {
-		if ( tlso_dhpem[i].keylength == key_length ) {
-			b = BIO_new_mem_buf( (char *)tlso_dhpem[i].pem, tlso_dhpem[i].size );
-			break;
-		}
-	}
-
-	if ( b ) {
-		dh = PEM_read_bio_DHparams( b, NULL, NULL, NULL );
-		BIO_free( b );
-	}
-
-	/* Generating on the fly is expensive/slow... */
-	if ( !dh ) {
-		dh = DH_generate_parameters( key_length, DH_GENERATOR_2, NULL, NULL );
-	}
-	if ( dh ) {
-		p = LDAP_MALLOC( sizeof(struct dhplist) );
-		if ( p != NULL ) {
-			p->keylength = key_length;
-			p->param = dh;
-			p->next = tlso_dhparams;
-			tlso_dhparams = p;
-		}
-	}
-
-	LDAP_MUTEX_UNLOCK( &tlso_dh_mutex );
-	return dh;
-}
 
 tls_impl ldap_int_tls_impl = {
 	"OpenSSL",

Index: src/external/bsd/openldap/dist/libraries/liblutil/detach.c
diff -u src/external/bsd/openldap/dist/libraries/liblutil/detach.c:1.4 src/external/bsd/openldap/dist/libraries/liblutil/detach.c:1.5
--- src/external/bsd/openldap/dist/libraries/liblutil/detach.c:1.4	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/libraries/liblutil/detach.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: detach.c,v 1.4 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: detach.c,v 1.5 2018/02/06 01:57:23 christos Exp $	*/
 
 /* detach.c -- routines to daemonize a process */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: detach.c,v 1.4 2017/02/09 01:53:51 christos Exp $");
+__RCSID("$NetBSD: detach.c,v 1.5 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 
Index: src/external/bsd/openldap/dist/libraries/liblutil/md5.c
diff -u src/external/bsd/openldap/dist/libraries/liblutil/md5.c:1.4 src/external/bsd/openldap/dist/libraries/liblutil/md5.c:1.5
--- src/external/bsd/openldap/dist/libraries/liblutil/md5.c:1.4	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/libraries/liblutil/md5.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: md5.c,v 1.4 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: md5.c,v 1.5 2018/02/06 01:57:23 christos Exp $	*/
 
 /* md5.c -- MD5 message-digest algorithm */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,7 @@
    public domain.  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: md5.c,v 1.4 2017/02/09 01:53:51 christos Exp $");
+__RCSID("$NetBSD: md5.c,v 1.5 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 

Index: src/external/bsd/openldap/dist/libraries/liblutil/passwd.c
diff -u src/external/bsd/openldap/dist/libraries/liblutil/passwd.c:1.5 src/external/bsd/openldap/dist/libraries/liblutil/passwd.c:1.6
--- src/external/bsd/openldap/dist/libraries/liblutil/passwd.c:1.5	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/libraries/liblutil/passwd.c	Mon Feb  5 20:57:23 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: passwd.c,v 1.5 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: passwd.c,v 1.6 2018/02/06 01:57:23 christos Exp $	*/
 
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: passwd.c,v 1.5 2017/02/09 01:53:51 christos Exp $");
+__RCSID("$NetBSD: passwd.c,v 1.6 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 
@@ -44,9 +44,9 @@ __RCSID("$NetBSD: passwd.c,v 1.5 2017/02
 #	include <openssl/des.h>
 
 
-typedef des_cblock des_key;
-typedef des_cblock des_data_block;
-typedef des_key_schedule des_context;
+typedef DES_cblock des_key;
+typedef DES_cblock des_data_block;
+typedef DES_key_schedule des_context[1];
 #define des_failed(encrypted) 0
 #define des_finish(key, schedule) 
 
@@ -673,7 +673,7 @@ static void
 des_set_key_and_parity( des_key *key, unsigned char *keyData)
 {
     memcpy(key, keyData, 8);
-    des_set_odd_parity( key );
+    DES_set_odd_parity( key );
 }
 
 
@@ -705,7 +705,7 @@ des_set_key_and_parity( des_key *key, un
 }
 
 static void
-des_set_key_unchecked( des_key *key, des_context ctxt )
+DES_set_key_unchecked( des_key *key, des_context ctxt )
 {
     ctxt[0] = NULL;
 
@@ -718,7 +718,7 @@ des_set_key_unchecked( des_key *key, des
 }
 
 static void
-des_ecb_encrypt( des_data_block *plain, des_data_block *encrypted, 
+DES_ecb_encrypt( des_data_block *plain, des_data_block *encrypted,
 			des_context ctxt, int op)
 {
     SECStatus rv;
@@ -870,16 +870,16 @@ static int chk_lanman(
 	ldap_pvt_str2upper( UcasePassword );
 	
 	lmPasswd_to_key( UcasePassword, &key );
-	des_set_key_unchecked( &key, schedule );
-	des_ecb_encrypt( &StdText, &PasswordHash1, schedule , DES_ENCRYPT );
+	DES_set_key_unchecked( &key, schedule );
+	DES_ecb_encrypt( &StdText, &PasswordHash1, schedule , DES_ENCRYPT );
 
 	if (des_failed(&PasswordHash1)) {
 	    return LUTIL_PASSWD_ERR;
 	}
 	
 	lmPasswd_to_key( &UcasePassword[7], &key );
-	des_set_key_unchecked( &key, schedule );
-	des_ecb_encrypt( &StdText, &PasswordHash2, schedule , DES_ENCRYPT );
+	DES_set_key_unchecked( &key, schedule );
+	DES_ecb_encrypt( &StdText, &PasswordHash2, schedule , DES_ENCRYPT );
 	if (des_failed(&PasswordHash2)) {
 	    return LUTIL_PASSWD_ERR;
 	}
@@ -1166,12 +1166,12 @@ static int hash_lanman(
 	ldap_pvt_str2upper( UcasePassword );
 	
 	lmPasswd_to_key( UcasePassword, &key );
-	des_set_key_unchecked( &key, schedule );
-	des_ecb_encrypt( &StdText, &PasswordHash1, schedule , DES_ENCRYPT );
+	DES_set_key_unchecked( &key, schedule );
+	DES_ecb_encrypt( &StdText, &PasswordHash1, schedule , DES_ENCRYPT );
 	
 	lmPasswd_to_key( &UcasePassword[7], &key );
-	des_set_key_unchecked( &key, schedule );
-	des_ecb_encrypt( &StdText, &PasswordHash2, schedule , DES_ENCRYPT );
+	DES_set_key_unchecked( &key, schedule );
+	DES_ecb_encrypt( &StdText, &PasswordHash2, schedule , DES_ENCRYPT );
 	
 	sprintf( PasswordHash, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", 
 		PasswordHash1[0],PasswordHash1[1],PasswordHash1[2],PasswordHash1[3],

Index: src/external/bsd/openldap/dist/libraries/librewrite/session.c
diff -u src/external/bsd/openldap/dist/libraries/librewrite/session.c:1.3 src/external/bsd/openldap/dist/libraries/librewrite/session.c:1.4
--- src/external/bsd/openldap/dist/libraries/librewrite/session.c:1.3	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/libraries/librewrite/session.c	Mon Feb  5 20:57:23 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: session.c,v 1.3 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: session.c,v 1.4 2018/02/06 01:57:23 christos Exp $	*/
 
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2016 The OpenLDAP Foundation.
+ * Copyright 2000-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Index: src/external/bsd/openldap/dist/servers/slapd/filter.c
diff -u src/external/bsd/openldap/dist/servers/slapd/filter.c:1.4 src/external/bsd/openldap/dist/servers/slapd/filter.c:1.5
--- src/external/bsd/openldap/dist/servers/slapd/filter.c:1.4	Wed Feb  8 21:20:33 2017
+++ src/external/bsd/openldap/dist/servers/slapd/filter.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: filter.c,v 1.4 2017/02/09 02:20:33 christos Exp $	*/
+/*	$NetBSD: filter.c,v 1.5 2018/02/06 01:57:23 christos Exp $	*/
 
 /* filter.c - routines for parsing and dealing with filters */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: filter.c,v 1.4 2017/02/09 02:20:33 christos Exp $");
+__RCSID("$NetBSD: filter.c,v 1.5 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 

Index: src/external/bsd/openldap/dist/servers/slapd/overlays/deref.c
diff -u src/external/bsd/openldap/dist/servers/slapd/overlays/deref.c:1.3 src/external/bsd/openldap/dist/servers/slapd/overlays/deref.c:1.4
--- src/external/bsd/openldap/dist/servers/slapd/overlays/deref.c:1.3	Wed Feb  8 20:53:51 2017
+++ src/external/bsd/openldap/dist/servers/slapd/overlays/deref.c	Mon Feb  5 20:57:23 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: deref.c,v 1.3 2017/02/09 01:53:51 christos Exp $	*/
+/*	$NetBSD: deref.c,v 1.4 2018/02/06 01:57:23 christos Exp $	*/
 
 /* deref.c - dereference overlay */
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2016 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * Portions Copyright 2008 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: deref.c,v 1.3 2017/02/09 01:53:51 christos Exp $");
+__RCSID("$NetBSD: deref.c,v 1.4 2018/02/06 01:57:23 christos Exp $");
 
 #include "portable.h"
 

Reply via email to