From: Hans Leidekker hans@codeweavers.com
Signed-off-by: Hans Leidekker hans@codeweavers.com --- libs/ldap/include/ac/socket.h | 3 +++ libs/ldap/liblber/memory.c | 48 ++++++++++++++++++++--------------- libs/ldap/libldap/charray.c | 2 +- libs/ldap/libldap/cyrus.c | 2 +- libs/ldap/libldap/sasl.c | 2 +- libs/ldap/libldap/thr_nt.c | 1 + libs/ldap/libldap/util-int.c | 2 +- 7 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/libs/ldap/include/ac/socket.h b/libs/ldap/include/ac/socket.h index 65f07b25e8a..e2d32afb3a8 100644 --- a/libs/ldap/include/ac/socket.h +++ b/libs/ldap/include/ac/socket.h @@ -98,6 +98,9 @@ # define tcp_close( s ) closesocket( s ) # endif
+#undef EWOULDBLOCK +#undef EINPROGRESS +#undef ETIMEDOUT #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS #define ETIMEDOUT WSAETIMEDOUT diff --git a/libs/ldap/liblber/memory.c b/libs/ldap/liblber/memory.c index 2f91b5c111f..ef2ac095f4f 100644 --- a/libs/ldap/liblber/memory.c +++ b/libs/ldap/liblber/memory.c @@ -490,35 +490,41 @@ ber_dupbv_x( }
if ( dst ) { - new = &tmp; + if ( src->bv_val == NULL ) { + tmp.bv_val = NULL; + tmp.bv_len = 0; + } else { + + if(( tmp.bv_val = ber_memalloc_x( src->bv_len + 1, ctx )) == NULL ) { + return NULL; + } + + AC_MEMCPY( tmp.bv_val, src->bv_val, src->bv_len ); + tmp.bv_val[src->bv_len] = '\0'; + tmp.bv_len = src->bv_len; + } + *dst = tmp; + return dst; } else { if(( new = ber_memalloc_x( sizeof(struct berval), ctx )) == NULL ) { return NULL; } - } - - if ( src->bv_val == NULL ) { - new->bv_val = NULL; - new->bv_len = 0; - } else {
- if(( new->bv_val = ber_memalloc_x( src->bv_len + 1, ctx )) == NULL ) { - if ( !dst ) - ber_memfree_x( new, ctx ); - return NULL; - } + if ( src->bv_val == NULL ) { + new->bv_val = NULL; + new->bv_len = 0; + } else {
- AC_MEMCPY( new->bv_val, src->bv_val, src->bv_len ); - new->bv_val[src->bv_len] = '\0'; - new->bv_len = src->bv_len; - } + if(( new->bv_val = ber_memalloc_x( src->bv_len + 1, ctx )) == NULL ) { + return NULL; + }
- if ( dst ) { - *dst = *new; - new = dst; + AC_MEMCPY( new->bv_val, src->bv_val, src->bv_len ); + new->bv_val[src->bv_len] = '\0'; + new->bv_len = src->bv_len; + } + return new; } - - return new; }
struct berval * diff --git a/libs/ldap/libldap/charray.c b/libs/ldap/libldap/charray.c index d8c65ad8b2f..cd83290c86d 100644 --- a/libs/ldap/libldap/charray.c +++ b/libs/ldap/libldap/charray.c @@ -266,7 +266,7 @@ char * ldap_charray2str( char **a, const char *sep ) }
len = strlen( *v ); - strncpy( p, *v, len ); + memcpy( p, *v, len ); p += len; }
diff --git a/libs/ldap/libldap/cyrus.c b/libs/ldap/libldap/cyrus.c index 0d1be34f83c..d7111ace6f9 100644 --- a/libs/ldap/libldap/cyrus.c +++ b/libs/ldap/libldap/cyrus.c @@ -15,6 +15,7 @@
#include "portable.h"
+#include <ac/errno.h> #include "ldap-int.h"
#ifdef HAVE_CYRUS_SASL @@ -25,7 +26,6 @@ #include <ac/stdlib.h> #include <ac/string.h> #include <ac/time.h> -#include <ac/errno.h> #include <ac/ctype.h> #include <ac/unistd.h>
diff --git a/libs/ldap/libldap/sasl.c b/libs/ldap/libldap/sasl.c index c6a96d9f524..32974c6c8e2 100644 --- a/libs/ldap/libldap/sasl.c +++ b/libs/ldap/libldap/sasl.c @@ -36,11 +36,11 @@
#include <stdio.h>
+#include <ac/errno.h> #include <ac/socket.h> #include <ac/stdlib.h> #include <ac/string.h> #include <ac/time.h> -#include <ac/errno.h>
#include "ldap-int.h"
diff --git a/libs/ldap/libldap/thr_nt.c b/libs/ldap/libldap/thr_nt.c index 95c2420b555..def4da706f8 100644 --- a/libs/ldap/libldap/thr_nt.c +++ b/libs/ldap/libldap/thr_nt.c @@ -18,6 +18,7 @@
#if defined( HAVE_NT_THREADS )
+#undef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #include <windows.h> #include <process.h> diff --git a/libs/ldap/libldap/util-int.c b/libs/ldap/libldap/util-int.c index 642ab4b0b88..07a6f423463 100644 --- a/libs/ldap/libldap/util-int.c +++ b/libs/ldap/libldap/util-int.c @@ -187,7 +187,7 @@ static int _ldap_pvt_gt_offset;
#define SEC_TO_UNIX_EPOCH 11644473600LL #define TICKS_PER_SECOND 10000000 -#define BILLION 1000000000L +#define BILLION 1000000000LL
static int ldap_pvt_gettimensec(int *sec)