mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-01 14:15:49 +08:00
Remove LBER_{TAG,INT,LEN}_{NTOH,HTON} macros. Rewrite code to
manual push bytes about. Allows ber_*_t to be any 32-bit or larger type. Reworked AC_{HTON,NTOH}{L,S} macros to care only about 32-bit (netlong) and 16-bit (netshort) reordering as needed for BSD socket interface.
This commit is contained in:
parent
3978748e35
commit
8b99e6cdbd
100
configure
vendored
100
configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# $OpenLDAP$
|
||||
# from OpenLDAP: pkg/ldap/configure.in,v 1.280 1999/11/25 16:10:51 kdz Exp
|
||||
# from OpenLDAP: pkg/ldap/configure.in,v 1.279 1999/11/17 01:26:55 kdz Exp
|
||||
|
||||
# Copyright 1998,1999 The OpenLDAP Foundation. All Rights Reserved.
|
||||
#
|
||||
@ -14052,14 +14052,20 @@ EOF
|
||||
|
||||
|
||||
|
||||
if test "$ac_cv_sizeof_long" -lt 4 ; then
|
||||
{ echo "configure: error: sizeof(long) < 4" 1>&2; exit 1; }
|
||||
fi
|
||||
if test "$ac_cv_sizeof_int" -lt 4 ; then
|
||||
echo "configure: warning: OpenLDAP requires 'int' to be 32 bits or greater." 1>&2
|
||||
|
||||
cat >> confdefs.h <<\EOF
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define LBER_INT_T long
|
||||
EOF
|
||||
|
||||
else
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define LBER_INT_T int
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define LBER_LEN_T long
|
||||
EOF
|
||||
@ -14074,7 +14080,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
|
||||
echo "configure:14078: checking for 8-bit clean memcmp" >&5
|
||||
echo "configure:14084: checking for 8-bit clean memcmp" >&5
|
||||
if eval "test \"\${ac_cv_func_memcmp_clean+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -14082,7 +14088,7 @@ else
|
||||
ac_cv_func_memcmp_clean=no
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14086 "configure"
|
||||
#line 14092 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
main()
|
||||
@ -14092,7 +14098,7 @@ main()
|
||||
}
|
||||
|
||||
EOF
|
||||
if { (eval echo configure:14096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:14102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_func_memcmp_clean=yes
|
||||
else
|
||||
@ -14110,12 +14116,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
|
||||
test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
|
||||
|
||||
echo $ac_n "checking for strftime""... $ac_c" 1>&6
|
||||
echo "configure:14114: checking for strftime" >&5
|
||||
echo "configure:14120: checking for strftime" >&5
|
||||
if eval "test \"\${ac_cv_func_strftime+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14119 "configure"
|
||||
#line 14125 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char strftime(); below. */
|
||||
@ -14139,7 +14145,7 @@ f = strftime;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14149: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_strftime=yes"
|
||||
else
|
||||
@ -14161,7 +14167,7 @@ else
|
||||
echo "$ac_t""no" 1>&6
|
||||
# strftime is in -lintl on SCO UNIX.
|
||||
echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6
|
||||
echo "configure:14165: checking for strftime in -lintl" >&5
|
||||
echo "configure:14171: checking for strftime in -lintl" >&5
|
||||
ac_lib_var=`echo intl'_'strftime | sed 'y%./+-:%__p__%'`
|
||||
if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@ -14169,7 +14175,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lintl $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14173 "configure"
|
||||
#line 14179 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@ -14180,7 +14186,7 @@ int main() {
|
||||
strftime()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
@ -14208,12 +14214,12 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for inet_aton()""... $ac_c" 1>&6
|
||||
echo "configure:14212: checking for inet_aton()" >&5
|
||||
echo "configure:14218: checking for inet_aton()" >&5
|
||||
if eval "test \"\${ol_cv_func_inet_aton+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14217 "configure"
|
||||
#line 14223 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
@ -14235,7 +14241,7 @@ struct in_addr in;
|
||||
int rc = inet_aton( "255.255.255.255", &in );
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
ol_cv_func_inet_aton=yes
|
||||
else
|
||||
@ -14257,12 +14263,12 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking for _spawnlp""... $ac_c" 1>&6
|
||||
echo "configure:14261: checking for _spawnlp" >&5
|
||||
echo "configure:14267: checking for _spawnlp" >&5
|
||||
if eval "test \"\${ac_cv_func__spawnlp+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14266 "configure"
|
||||
#line 14272 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char _spawnlp(); below. */
|
||||
@ -14286,7 +14292,7 @@ f = _spawnlp;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func__spawnlp=yes"
|
||||
else
|
||||
@ -14310,12 +14316,12 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for _snprintf""... $ac_c" 1>&6
|
||||
echo "configure:14314: checking for _snprintf" >&5
|
||||
echo "configure:14320: checking for _snprintf" >&5
|
||||
if eval "test \"\${ac_cv_func__snprintf+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14319 "configure"
|
||||
#line 14325 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char _snprintf(); below. */
|
||||
@ -14339,7 +14345,7 @@ f = _snprintf;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func__snprintf=yes"
|
||||
else
|
||||
@ -14365,12 +14371,12 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for _vsnprintf""... $ac_c" 1>&6
|
||||
echo "configure:14369: checking for _vsnprintf" >&5
|
||||
echo "configure:14375: checking for _vsnprintf" >&5
|
||||
if eval "test \"\${ac_cv_func__vsnprintf+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14374 "configure"
|
||||
#line 14380 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char _vsnprintf(); below. */
|
||||
@ -14394,7 +14400,7 @@ f = _vsnprintf;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func__vsnprintf=yes"
|
||||
else
|
||||
@ -14420,12 +14426,12 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
|
||||
echo "configure:14424: checking for vprintf" >&5
|
||||
echo "configure:14430: checking for vprintf" >&5
|
||||
if eval "test \"\${ac_cv_func_vprintf+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14429 "configure"
|
||||
#line 14435 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char vprintf(); below. */
|
||||
@ -14449,7 +14455,7 @@ f = vprintf;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14453: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_vprintf=yes"
|
||||
else
|
||||
@ -14473,12 +14479,12 @@ fi
|
||||
|
||||
if test "$ac_cv_func_vprintf" != yes; then
|
||||
echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
|
||||
echo "configure:14477: checking for _doprnt" >&5
|
||||
echo "configure:14483: checking for _doprnt" >&5
|
||||
if eval "test \"\${ac_cv_func__doprnt+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14482 "configure"
|
||||
#line 14488 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char _doprnt(); below. */
|
||||
@ -14502,7 +14508,7 @@ f = _doprnt;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14506: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14512: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func__doprnt=yes"
|
||||
else
|
||||
@ -14531,12 +14537,12 @@ if test $ac_cv_func_vprintf = yes ; then
|
||||
for ac_func in vsnprintf vsprintf
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:14535: checking for $ac_func" >&5
|
||||
echo "configure:14541: checking for $ac_func" >&5
|
||||
if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14540 "configure"
|
||||
#line 14546 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -14560,7 +14566,7 @@ f = $ac_func;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -14637,12 +14643,12 @@ for ac_func in \
|
||||
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:14641: checking for $ac_func" >&5
|
||||
echo "configure:14647: checking for $ac_func" >&5
|
||||
if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14646 "configure"
|
||||
#line 14652 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -14666,7 +14672,7 @@ f = $ac_func;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -14694,12 +14700,12 @@ done
|
||||
for ac_func in getopt tempnam
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:14698: checking for $ac_func" >&5
|
||||
echo "configure:14704: checking for $ac_func" >&5
|
||||
if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14703 "configure"
|
||||
#line 14709 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -14723,7 +14729,7 @@ f = $ac_func;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -14760,13 +14766,13 @@ fi
|
||||
|
||||
# Check Configuration
|
||||
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
|
||||
echo "configure:14764: checking declaration of sys_errlist" >&5
|
||||
echo "configure:14770: checking declaration of sys_errlist" >&5
|
||||
if eval "test \"\${ol_cv_dcl_sys_errlist+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14770 "configure"
|
||||
#line 14776 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -14779,7 +14785,7 @@ int main() {
|
||||
char *c = (char *) *sys_errlist
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14783: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:14789: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ol_cv_dcl_sys_errlist=yes
|
||||
ol_cv_have_sys_errlist=yes
|
||||
@ -14802,20 +14808,20 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
|
||||
echo "configure:14806: checking existence of sys_errlist" >&5
|
||||
echo "configure:14812: checking existence of sys_errlist" >&5
|
||||
if eval "test \"\${ol_cv_have_sys_errlist+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 14812 "configure"
|
||||
#line 14818 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <errno.h>
|
||||
int main() {
|
||||
char *c = (char *) *sys_errlist
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:14819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:14825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
ol_cv_have_sys_errlist=yes
|
||||
else
|
||||
|
@ -1943,11 +1943,14 @@ AC_COMPILE_CHECK_SIZEOF(short)
|
||||
AC_COMPILE_CHECK_SIZEOF(int)
|
||||
AC_COMPILE_CHECK_SIZEOF(long)
|
||||
|
||||
if test "$ac_cv_sizeof_long" -lt 4 ; then
|
||||
AC_MSG_ERROR([sizeof(long) < 4])
|
||||
if test "$ac_cv_sizeof_int" -lt 4 ; then
|
||||
AC_MSG_WARN([OpenLDAP requires 'int' to be 32 bits or greater.])
|
||||
|
||||
AC_DEFINE(LBER_INT_T,long)
|
||||
else
|
||||
AC_DEFINE(LBER_INT_T,int)
|
||||
fi
|
||||
|
||||
AC_DEFINE(LBER_INT_T,long)
|
||||
AC_DEFINE(LBER_LEN_T,long)
|
||||
AC_DEFINE(LBER_SOCKET_T,int)
|
||||
AC_DEFINE(LBER_TAG_T,long)
|
||||
|
@ -144,26 +144,14 @@ LDAP_F( int ) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
|
||||
|
||||
#if defined(__WIN32) && defined(_ALPHA)
|
||||
/* NT on Alpha is hosed. */
|
||||
#define AC_HTONL( l ) \
|
||||
((((l)&0xff)<<24) + (((l)&0xff00)<<8) + \
|
||||
(((l)&0xff0000)>>8) + (((l)&0xff000000)>>24))
|
||||
#define AC_NTOHL(l) AC_HTONL(l)
|
||||
|
||||
#elif defined(__alpha) && !defined(VMS)
|
||||
/*
|
||||
* htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
|
||||
* lower-order 32-bits of a (64-bit) long, so we define correct versions
|
||||
* here.
|
||||
*/
|
||||
#define AC_HTONL( l ) (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
|
||||
| htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
|
||||
|
||||
#define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
|
||||
| ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
|
||||
# define AC_HTONL( l ) \
|
||||
((((l)&0xffU)<<24) + (((l)&0xff00U)<<8) + \
|
||||
(((l)&0xff0000U)>>8) + (((l)&0xff000000U)>>24))
|
||||
# define AC_NTOHL(l) AC_HTONL(l)
|
||||
|
||||
#else
|
||||
#define AC_HTONL( l ) htonl( l )
|
||||
#define AC_NTOHL( l ) ntohl( l )
|
||||
# define AC_HTONL( l ) htonl( l )
|
||||
# define AC_NTOHL( l ) ntohl( l )
|
||||
#endif
|
||||
|
||||
/* htons()/ntohs() may be broken much like htonl()/ntohl() */
|
||||
|
@ -26,7 +26,7 @@ LDAP_BEGIN_DECL
|
||||
*
|
||||
* bitsof(short) == 2
|
||||
* bitsof(int) == 4
|
||||
* bitsof(long) == 4
|
||||
* bitsof(long) == 4 /* or larger */
|
||||
*
|
||||
* typedef unsigned int size_t;
|
||||
* typedef unsigned int SOCKET;
|
||||
@ -35,7 +35,7 @@ LDAP_BEGIN_DECL
|
||||
*/
|
||||
|
||||
/* LBER boolean, enum, integers - 32 bits or larger*/
|
||||
#define LBER_INT_T long
|
||||
#define LBER_INT_T int
|
||||
|
||||
/* LBER tags - 32 bits or larger */
|
||||
#define LBER_TAG_T long
|
||||
|
@ -79,9 +79,8 @@ ber_skip_tag( BerElement *ber, ber_len_t *len )
|
||||
{
|
||||
ber_tag_t tag;
|
||||
unsigned char lc;
|
||||
ber_len_t noctets;
|
||||
int diff;
|
||||
ber_len_t netlen;
|
||||
ber_len_t i, noctets;
|
||||
unsigned char netlen[sizeof(ber_len_t)];
|
||||
|
||||
assert( ber != NULL );
|
||||
assert( len != NULL );
|
||||
@ -111,18 +110,27 @@ ber_skip_tag( BerElement *ber, ber_len_t *len )
|
||||
* greater than what we can hold in a ber_len_t.
|
||||
*/
|
||||
|
||||
*len = netlen = 0;
|
||||
*len = 0;
|
||||
|
||||
if ( ber_read( ber, (char *) &lc, 1 ) != 1 )
|
||||
return( LBER_DEFAULT );
|
||||
|
||||
if ( lc & 0x80U ) {
|
||||
noctets = (lc & 0x7fU);
|
||||
if ( noctets > sizeof(ber_len_t) )
|
||||
|
||||
if ( noctets > sizeof(ber_len_t) ) {
|
||||
return( LBER_DEFAULT );
|
||||
diff = sizeof(ber_len_t) - noctets;
|
||||
if ( (unsigned) ber_read( ber, (char *) &netlen + diff, noctets )
|
||||
!= noctets )
|
||||
}
|
||||
|
||||
if( (unsigned) ber_read( ber, netlen, noctets ) != noctets ) {
|
||||
return( LBER_DEFAULT );
|
||||
*len = LBER_LEN_NTOH( netlen );
|
||||
}
|
||||
|
||||
for( i = 0; i < noctets; i++ ) {
|
||||
*len <<= 8;
|
||||
*len |= netlen[i];
|
||||
}
|
||||
|
||||
} else {
|
||||
*len = lc;
|
||||
}
|
||||
|
@ -73,17 +73,22 @@ ber_put_tag(
|
||||
{
|
||||
int rc;
|
||||
ber_len_t taglen;
|
||||
ber_tag_t ntag;
|
||||
ber_len_t i;
|
||||
unsigned char nettag[sizeof(ber_tag_t)];
|
||||
ber_tag_t xtag;
|
||||
|
||||
assert( ber != NULL );
|
||||
assert( BER_VALID( ber ) );
|
||||
|
||||
taglen = ber_calc_taglen( tag );
|
||||
|
||||
ntag = LBER_TAG_HTON( tag );
|
||||
for( i=0; i<taglen; i++ ) {
|
||||
nettag[(sizeof(ber_tag_t)-1) - i] = tag & 0xffU;
|
||||
tag >>= 8;
|
||||
}
|
||||
|
||||
rc = ber_write( ber,
|
||||
((char *) &ntag) + sizeof(ber_tag_t) - taglen,
|
||||
&nettag[sizeof(ber_tag_t) - taglen],
|
||||
taglen, nosos );
|
||||
|
||||
return rc;
|
||||
@ -118,10 +123,12 @@ ber_calc_lenlen( ber_len_t len )
|
||||
static int
|
||||
ber_put_len( BerElement *ber, ber_len_t len, int nosos )
|
||||
{
|
||||
int i;
|
||||
int rc;
|
||||
int i,j;
|
||||
char lenlen;
|
||||
ber_len_t mask;
|
||||
ber_len_t netlen;
|
||||
unsigned char netlen[sizeof(ber_len_t)];
|
||||
ber_len_t xlen;
|
||||
|
||||
assert( ber != NULL );
|
||||
assert( BER_VALID( ber ) );
|
||||
@ -151,19 +158,24 @@ ber_put_len( BerElement *ber, ber_len_t len, int nosos )
|
||||
lenlen = (unsigned char) ++i;
|
||||
if ( lenlen > 4 )
|
||||
return( -1 );
|
||||
|
||||
lenlen |= 0x80UL;
|
||||
|
||||
/* write the length of the length */
|
||||
if ( ber_write( ber, &lenlen, 1, nosos ) != 1 )
|
||||
return( -1 );
|
||||
|
||||
/* write the length itself */
|
||||
netlen = LBER_LEN_HTON( len );
|
||||
if ( ber_write( ber, (char *) &netlen + (sizeof(ber_len_t) - i), i, nosos )
|
||||
!= i )
|
||||
return( -1 );
|
||||
for( j=0; j<i; j++) {
|
||||
netlen[(sizeof(ber_len_t)-1) - j] = len & 0xffU;
|
||||
len >>= 8;
|
||||
}
|
||||
|
||||
return( i + 1 );
|
||||
/* write the length itself */
|
||||
rc = ber_write( ber,
|
||||
&netlen[sizeof(ber_len_t)-i],
|
||||
i, nosos );
|
||||
|
||||
return rc == i ? i+1 : -1;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -172,9 +184,11 @@ ber_put_int_or_enum(
|
||||
ber_int_t num,
|
||||
ber_tag_t tag )
|
||||
{
|
||||
int i, sign;
|
||||
int rc;
|
||||
int i, j, sign;
|
||||
ber_len_t len, lenlen, taglen;
|
||||
ber_uint_t unum, netnum, mask;
|
||||
ber_uint_t unum, xnum, mask;
|
||||
unsigned char netnum[sizeof(ber_uint_t)];
|
||||
|
||||
assert( ber != NULL );
|
||||
assert( BER_VALID( ber ) );
|
||||
@ -216,13 +230,18 @@ ber_put_int_or_enum(
|
||||
if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 )
|
||||
return( -1 );
|
||||
i++;
|
||||
netnum = LBER_INT_HTON( unum );
|
||||
if ( ber_write( ber, (char *) &netnum + (sizeof(ber_int_t) - i), i, 0 )
|
||||
!= i )
|
||||
return( -1 );
|
||||
|
||||
for( j=0; j<i; j++ ) {
|
||||
netnum[(sizeof(ber_int_t)-1) - j] = unum & 0xffU;
|
||||
unum >>= 8;
|
||||
}
|
||||
|
||||
rc = ber_write( ber,
|
||||
&netnum[sizeof(ber_int_t) - i],
|
||||
i, 0 );
|
||||
|
||||
/* length of tag + length + contents */
|
||||
return( taglen + lenlen + i );
|
||||
return rc == i ? taglen + lenlen + i : -1;
|
||||
}
|
||||
|
||||
int
|
||||
@ -484,7 +503,9 @@ ber_start_set( BerElement *ber, ber_tag_t tag )
|
||||
static int
|
||||
ber_put_seqorset( BerElement *ber )
|
||||
{
|
||||
ber_len_t len, netlen;
|
||||
int rc, i;
|
||||
ber_len_t len;
|
||||
unsigned char netlen[sizeof(ber_len_t)];
|
||||
ber_len_t taglen, lenlen;
|
||||
unsigned char ltag = 0x80U + FOUR_BYTE_LEN - 1;
|
||||
Seqorset *next;
|
||||
@ -502,16 +523,25 @@ ber_put_seqorset( BerElement *ber )
|
||||
*/
|
||||
|
||||
len = (*sos)->sos_clen;
|
||||
netlen = LBER_LEN_HTON( len );
|
||||
|
||||
if ( sizeof(ber_len_t) > 4 && len > 0xffffffffUL )
|
||||
return( -1 );
|
||||
|
||||
if ( ber->ber_options & LBER_USE_DER ) {
|
||||
lenlen = ber_calc_lenlen( len );
|
||||
|
||||
} else {
|
||||
lenlen = FOUR_BYTE_LEN;
|
||||
}
|
||||
|
||||
if( lenlen > 1 ) {
|
||||
for( i=0; i < lenlen-1; i++ ) {
|
||||
netlen[(sizeof(ber_len_t)-1) - i] = (len >> i*8) & 0xffU;
|
||||
}
|
||||
} else {
|
||||
netlen[sizeof(ber_len_t)-1] = len & 0x7fU;
|
||||
}
|
||||
|
||||
if ( (next = (*sos)->sos_next) == NULL ) {
|
||||
/* write the tag */
|
||||
if ( (taglen = ber_put_tag( ber, (*sos)->sos_tag, 1 )) == -1 )
|
||||
@ -539,21 +569,33 @@ ber_put_seqorset( BerElement *ber )
|
||||
return( -1 );
|
||||
|
||||
/* the length itself */
|
||||
if ( ber_write( ber, (char *) (&netlen + 1)
|
||||
- (FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1, 1 )
|
||||
!= FOUR_BYTE_LEN - 1 )
|
||||
rc = ber_write( ber,
|
||||
&netlen[sizeof(ber_len_t) - (FOUR_BYTE_LEN-1)],
|
||||
FOUR_BYTE_LEN-1, 1 );
|
||||
|
||||
if( rc != FOUR_BYTE_LEN - 1 ) {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
/* The ber_ptr is at the set/seq start - move it to the end */
|
||||
(*sos)->sos_ber->ber_ptr += len;
|
||||
|
||||
} else {
|
||||
ber_tag_t ntag;
|
||||
int i;
|
||||
unsigned char nettag[sizeof(ber_tag_t)];
|
||||
ber_tag_t tmptag = (*sos)->sos_tag;
|
||||
|
||||
/* the tag */
|
||||
taglen = ber_calc_taglen( (*sos)->sos_tag );
|
||||
ntag = LBER_TAG_HTON( (*sos)->sos_tag );
|
||||
SAFEMEMCPY( (*sos)->sos_first, (char *) &ntag +
|
||||
sizeof(ber_tag_t) - taglen, taglen );
|
||||
taglen = ber_calc_taglen( tmptag );
|
||||
|
||||
for( i = 0; i < taglen; i++ ) {
|
||||
nettag[(sizeof(ber_tag_t)-1) - i] = tmptag & 0xffU;
|
||||
tmptag >>= 8;
|
||||
}
|
||||
|
||||
SAFEMEMCPY( (*sos)->sos_first,
|
||||
&nettag[sizeof(ber_tag_t) - taglen],
|
||||
taglen );
|
||||
|
||||
if ( ber->ber_options & LBER_USE_DER ) {
|
||||
ltag = (lenlen == 1)
|
||||
@ -568,9 +610,8 @@ ber_put_seqorset( BerElement *ber )
|
||||
if (lenlen > 1) {
|
||||
/* Write the length itself */
|
||||
SAFEMEMCPY( (*sos)->sos_first + 2,
|
||||
(char *)&netlen + sizeof(ber_len_t) -
|
||||
(lenlen - 1),
|
||||
lenlen - 1 );
|
||||
&netlen[sizeof(ber_len_t) - (lenlen - 1)],
|
||||
lenlen - 1 );
|
||||
}
|
||||
if (lenlen != FOUR_BYTE_LEN) {
|
||||
/*
|
||||
@ -585,8 +626,8 @@ ber_put_seqorset( BerElement *ber )
|
||||
} else {
|
||||
/* the length itself */
|
||||
SAFEMEMCPY( (*sos)->sos_first + taglen + 1,
|
||||
(char *) &netlen + sizeof(ber_len_t) -
|
||||
(FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1 );
|
||||
&netlen[sizeof(ber_len_t) - (FOUR_BYTE_LEN - 1)],
|
||||
FOUR_BYTE_LEN - 1 );
|
||||
}
|
||||
|
||||
next->sos_clen += (taglen + lenlen + len);
|
||||
|
@ -523,8 +523,9 @@ ber_get_next(
|
||||
ber->ber_tag = 0;
|
||||
}
|
||||
|
||||
#define PTR_IN_VAR( ptr, var )\
|
||||
(((ptr)>=(char *) &(var)) && ((ptr)< (char *) &(var)+sizeof(var)))
|
||||
#undef PTR_IN_VAR
|
||||
#define PTR_IN_VAR( ptr, var ) \
|
||||
(((ptr)>=(char *) &(var)) && ((ptr)< (char *) &(var)+sizeof(var)))
|
||||
|
||||
if (PTR_IN_VAR(ber->ber_rwptr, ber->ber_tag)) {
|
||||
if (ber->ber_rwptr == (char *) &ber->ber_tag) {
|
||||
@ -548,10 +549,11 @@ ber_get_next(
|
||||
ber->ber_rwptr = (char *) &ber->ber_usertag;
|
||||
goto get_lenbyte;
|
||||
}
|
||||
} while (PTR_IN_VAR(ber->ber_rwptr,ber->ber_tag));
|
||||
} while( PTR_IN_VAR(ber->ber_rwptr, ber->ber_tag ));
|
||||
errno = ERANGE; /* this is a serious error. */
|
||||
return LBER_DEFAULT;
|
||||
}
|
||||
|
||||
get_lenbyte:
|
||||
if (ber->ber_rwptr==(char *) &ber->ber_usertag) {
|
||||
unsigned char c;
|
||||
@ -571,19 +573,28 @@ get_lenbyte:
|
||||
goto fill_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
if (PTR_IN_VAR(ber->ber_rwptr, ber->ber_len)) {
|
||||
unsigned char netlen[sizeof(ber_len_t)];
|
||||
|
||||
ber_slen_t res;
|
||||
ber_slen_t to_go;
|
||||
to_go = (char *) &ber->ber_len + sizeof( ber->ber_len ) -
|
||||
ber->ber_rwptr;
|
||||
assert( to_go > 0 );
|
||||
res = ber_pvt_sb_read( sb, ber->ber_rwptr, to_go );
|
||||
if (res <=0)
|
||||
res = ber_pvt_sb_read( sb, netlen, to_go );
|
||||
if (res <= 0) {
|
||||
return LBER_DEFAULT;
|
||||
}
|
||||
ber->ber_rwptr += res;
|
||||
|
||||
if (res==to_go) {
|
||||
/* convert length. */
|
||||
ber->ber_len = LBER_LEN_NTOH( ber->ber_len );
|
||||
ber->ber_len = 0;
|
||||
for( to_go = 0; to_go < res ; to_go++ ) {
|
||||
ber->ber_len <<= 8;
|
||||
ber->ber_len |= netlen[to_go];
|
||||
}
|
||||
goto fill_buffer;
|
||||
} else {
|
||||
#if defined( EWOULDBLOCK )
|
||||
@ -594,6 +605,7 @@ get_lenbyte:
|
||||
return LBER_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
fill_buffer:
|
||||
/* now fill the buffer. */
|
||||
if (ber->ber_buf==NULL) {
|
||||
@ -608,6 +620,7 @@ fill_buffer:
|
||||
ber->ber_ptr = ber->ber_buf;
|
||||
ber->ber_end = ber->ber_buf + ber->ber_len;
|
||||
}
|
||||
|
||||
if ((ber->ber_rwptr>=ber->ber_buf) && (ber->ber_rwptr<ber->ber_end)) {
|
||||
ber_slen_t res;
|
||||
ber_slen_t to_go;
|
||||
|
@ -26,14 +26,6 @@ LDAP_BEGIN_DECL
|
||||
|
||||
extern BER_ERRNO_FN ber_int_errno_fn;
|
||||
|
||||
/* these have to match lber types settings */
|
||||
#define LBER_INT_HTON(i) AC_HTONL(i)
|
||||
#define LBER_INT_NTOH(i) AC_NTOHL(i)
|
||||
#define LBER_LEN_HTON(l) AC_HTONL(l)
|
||||
#define LBER_LEN_NTOH(l) AC_NTOHL(l)
|
||||
#define LBER_TAG_HTON(t) AC_HTONL(t)
|
||||
#define LBER_TAG_NTOH(t) AC_NTOHL(t)
|
||||
|
||||
struct lber_options {
|
||||
short lbo_valid;
|
||||
#define LBER_UNINITIALIZED 0x0
|
||||
|
Loading…
Reference in New Issue
Block a user