summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2005-05-08 16:06:25 +0000
committerfoobar <sniper@php.net>2005-05-08 16:06:25 +0000
commit49b5d46a76d15823c151b1b4da2cb57fed72f999 (patch)
tree2f4b1b7691c29a14246e03fff47386788f71bdf5 /ext
parent01ee1225dc9c6c8c319414d60761e9e4c66db739 (diff)
downloadphp-git-49b5d46a76d15823c151b1b4da2cb57fed72f999.tar.gz
MFH: - Fixed bug #32932 (Oracle LDAP: ldap_get_entries invalid pointer)
# also partial sync with HEAD (just some ws/cs changes)
Diffstat (limited to 'ext')
-rw-r--r--ext/ldap/config.m418
-rw-r--r--ext/ldap/ldap.c59
-rw-r--r--ext/ldap/php_ldap.h22
3 files changed, 55 insertions, 44 deletions
diff --git a/ext/ldap/config.m4 b/ext/ldap/config.m4
index 7555f43ccb..28dd19491d 100644
--- a/ext/ldap/config.m4
+++ b/ext/ldap/config.m4
@@ -99,7 +99,9 @@ if test "$PHP_LDAP" != "no"; then
elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME; then
PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
AC_DEFINE(HAVE_ORALDAP,1,[ ])
-
+ if test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
+ AC_DEFINE(HAVE_ORALDAP_10,1,[ ])
+ fi
else
AC_MSG_ERROR(Cannot find ldap libraries in $LDAP_LIBDIR.)
fi
@@ -112,8 +114,6 @@ if test "$PHP_LDAP" != "no"; then
_SAVE_CPPFLAGS=$CPPFLAGS
_SAVE_LDFLAGS=$LDFLAGS
CPPFLAGS="$CPPFLAGS -I$LDAP_INCDIR"
- LDFLAGS="$LDFLAGS $LDAP_SHARED_LIBADD"
-
AC_CACHE_CHECK([for 3 arg ldap_set_rebind_proc], ac_cv_3arg_setrebindproc,
[AC_TRY_COMPILE([#include <ldap.h>], [ldap_set_rebind_proc(0,0,0)],
ac_cv_3arg_setrebindproc=yes, ac_cv_3arg_setrebindproc=no)])
@@ -124,6 +124,16 @@ if test "$PHP_LDAP" != "no"; then
dnl Solaris 2.8 claims to be 2004 API, but doesn't have
dnl ldap_parse_reference() nor ldap_start_tls_s()
- AC_CHECK_FUNCS([ldap_parse_reference ldap_start_tls_s])
+ AC_CHECK_FUNCS([ldap_parse_result ldap_parse_reference ldap_start_tls_s])
+ LDFLAGS=$_SAVE_LDFLAGS
+
+ dnl
+ dnl Sanity check
+ dnl
+ _SAVE_LDFLAGS=$LDFLAGS
+ LDFLAGS="$LDFLAGS $LDAP_SHARED_LIBADD"
+ AC_CHECK_FUNC(ldap_bind_s, [], [
+ AC_MSG_ERROR([LDAP build check failed. Please check config.log for more information.])
+ ])
LDFLAGS=$_SAVE_LDFLAGS
fi
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index ef90adf046..a587cdb72a 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -121,16 +121,18 @@ function_entry ldap_functions[] = {
PHP_FE(ldap_compare, NULL)
PHP_FE(ldap_sort, NULL)
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
+ PHP_FE(ldap_rename, NULL)
PHP_FE(ldap_get_option, third_argument_force_ref)
PHP_FE(ldap_set_option, NULL)
- PHP_FE(ldap_parse_result, arg3to6of6_force_ref)
PHP_FE(ldap_first_reference, NULL)
PHP_FE(ldap_next_reference, NULL)
#ifdef HAVE_LDAP_PARSE_REFERENCE
PHP_FE(ldap_parse_reference, third_argument_force_ref)
#endif
- PHP_FE(ldap_rename, NULL)
+#ifdef HAVE_LDAP_PARSE_RESULT
+ PHP_FE(ldap_parse_result, arg3to6of6_force_ref)
+#endif
#ifdef HAVE_LDAP_START_TLS_S
PHP_FE(ldap_start_tls, NULL)
#endif
@@ -223,7 +225,7 @@ PHP_MINIT_FUNCTION(ldap)
REGISTER_LONG_CONSTANT("LDAP_DEREF_FINDING", LDAP_DEREF_FINDING, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_DEREF_ALWAYS", LDAP_DEREF_ALWAYS, CONST_PERSISTENT | CONST_CS);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
/* LDAP options */
REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, CONST_PERSISTENT | CONST_CS);
@@ -234,7 +236,9 @@ PHP_MINIT_FUNCTION(ldap)
#ifdef LDAP_OPT_RESTART
REGISTER_LONG_CONSTANT("LDAP_OPT_RESTART", LDAP_OPT_RESTART, CONST_PERSISTENT | CONST_CS);
#endif
+#ifdef LDAP_OPT_HOST_NAME
REGISTER_LONG_CONSTANT("LDAP_OPT_HOST_NAME", LDAP_OPT_HOST_NAME, CONST_PERSISTENT | CONST_CS);
+#endif
REGISTER_LONG_CONSTANT("LDAP_OPT_ERROR_STRING", LDAP_OPT_ERROR_STRING, CONST_PERSISTENT | CONST_CS);
#ifdef LDAP_OPT_MATCHED_DN
REGISTER_LONG_CONSTANT("LDAP_OPT_MATCHED_DN", LDAP_OPT_MATCHED_DN, CONST_PERSISTENT | CONST_CS);
@@ -414,7 +418,7 @@ PHP_FUNCTION(ldap_connect)
static int _get_lderrno(LDAP *ldap)
{
#if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000
+#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP_10
int lderr;
/* New versions of OpenLDAP do it this way */
@@ -478,7 +482,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
{
/* sizelimit */
if (sizelimit > -1) {
-#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
+#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
ldap_set_option(ldap, LDAP_OPT_SIZELIMIT, &sizelimit);
#else
ldap->ld_sizelimit = sizelimit;
@@ -487,7 +491,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
/* timelimit */
if (timelimit > -1) {
-#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
+#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit);
#else
ldap->ld_timelimit = timelimit;
@@ -496,7 +500,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
/* deref */
if (deref > -1) {
-#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
+#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#else
ldap->ld_deref = deref;
@@ -915,12 +919,12 @@ PHP_FUNCTION(ldap_get_entries)
add_index_string(tmp1, num_attrib, attribute, 1);
num_attrib++;
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
}
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
if (ber != NULL)
ber_free(ber, 0);
#endif
@@ -928,7 +932,7 @@ PHP_FUNCTION(ldap_get_entries)
add_assoc_long(tmp1, "count", num_attrib);
dn = ldap_get_dn(ldap, ldap_result_entry);
add_assoc_string(tmp1, "dn", dn, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(dn);
#else
free(dn);
@@ -968,7 +972,7 @@ PHP_FUNCTION(ldap_first_attribute)
ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
RETVAL_STRING(attribute, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
}
@@ -999,7 +1003,7 @@ PHP_FUNCTION(ldap_next_attribute)
ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
RETVAL_STRING(attribute, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
}
@@ -1046,12 +1050,12 @@ PHP_FUNCTION(ldap_get_attributes)
add_index_string(return_value, num_attrib, attribute, 1);
num_attrib++;
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
attribute = ldap_next_attribute(ld->link, resultentry->data, ber);
}
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
if (ber != NULL) {
ber_free(ber, 0);
}
@@ -1159,7 +1163,7 @@ PHP_FUNCTION(ldap_get_dn)
text = ldap_get_dn(ld->link, resultentry->data);
if (text != NULL) {
RETVAL_STRING(text, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(text);
#else
free(text);
@@ -1222,7 +1226,7 @@ PHP_FUNCTION(ldap_dn2ufn)
if (ufn !=NULL) {
RETVAL_STRING(ufn, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(ufn);
#endif
} else {
@@ -1542,8 +1546,7 @@ PHP_FUNCTION(ldap_sort)
}
/* }}} */
-
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
/* {{{ proto bool ldap_get_option(resource link, int option, mixed retval)
Get the current value of various session-wide parameters */
PHP_FUNCTION(ldap_get_option)
@@ -1581,8 +1584,10 @@ PHP_FUNCTION(ldap_get_option)
ZVAL_LONG(*retval, val);
} break;
/* options with string value */
- case LDAP_OPT_HOST_NAME:
case LDAP_OPT_ERROR_STRING:
+#ifdef LDAP_OPT_HOST_NAME
+ case LDAP_OPT_HOST_NAME:
+#endif
#ifdef LDAP_OPT_MATCHED_DN
case LDAP_OPT_MATCHED_DN:
#endif
@@ -1636,7 +1641,7 @@ PHP_FUNCTION(ldap_set_option)
opt = Z_LVAL_PP(option);
switch (opt) {
- /* options with int value */
+ /* options with int value */
case LDAP_OPT_DEREF:
case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT:
@@ -1653,9 +1658,11 @@ PHP_FUNCTION(ldap_set_option)
RETURN_FALSE;
}
} break;
- /* options with string value */
- case LDAP_OPT_HOST_NAME:
+ /* options with string value */
case LDAP_OPT_ERROR_STRING:
+#ifdef LDAP_OPT_HOST_NAME
+ case LDAP_OPT_HOST_NAME:
+#endif
#ifdef LDAP_OPT_MATCHED_DN
case LDAP_OPT_MATCHED_DN:
#endif
@@ -1751,6 +1758,7 @@ PHP_FUNCTION(ldap_set_option)
}
/* }}} */
+#ifdef HAVE_LDAP_PARSE_RESULT
/* {{{ proto bool ldap_parse_result(resource link, resource result, int errcode, string matcheddn, string errmsg, array referrals)
Extract information from result */
PHP_FUNCTION(ldap_parse_result)
@@ -1816,6 +1824,7 @@ PHP_FUNCTION(ldap_parse_result)
RETURN_TRUE;
}
/* }}} */
+#endif
/* {{{ proto resource ldap_first_reference(resource link, resource result)
Return first reference */
@@ -1928,7 +1937,7 @@ PHP_FUNCTION(ldap_rename)
convert_to_string_ex(newparent);
convert_to_boolean_ex(deleteoldrdn);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
rc = ldap_rename_s(ld->link, Z_STRVAL_PP(dn), Z_STRVAL_PP(newrdn), Z_STRVAL_PP(newparent), Z_BVAL_PP(deleteoldrdn), NULL, NULL);
#else
if (Z_STRLEN_PP(newparent) != 0) {
@@ -1972,7 +1981,7 @@ PHP_FUNCTION(ldap_start_tls)
}
/* }}} */
#endif
-#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP */
+#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 */
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
/* {{{ _ldap_rebind_proc()
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index 99bb9b7217..288c79caf2 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -34,59 +34,51 @@ extern zend_module_entry ldap_module_entry;
/* LDAP functions */
PHP_MINIT_FUNCTION(ldap);
PHP_MSHUTDOWN_FUNCTION(ldap);
-
PHP_MINFO_FUNCTION(ldap);
PHP_FUNCTION(ldap_connect);
-
PHP_FUNCTION(ldap_bind);
PHP_FUNCTION(ldap_unbind);
-
PHP_FUNCTION(ldap_read);
PHP_FUNCTION(ldap_list);
PHP_FUNCTION(ldap_search);
-
PHP_FUNCTION(ldap_free_result);
PHP_FUNCTION(ldap_count_entries);
-
PHP_FUNCTION(ldap_first_entry);
PHP_FUNCTION(ldap_next_entry);
PHP_FUNCTION(ldap_get_entries);
PHP_FUNCTION(ldap_first_attribute);
PHP_FUNCTION(ldap_next_attribute);
PHP_FUNCTION(ldap_get_attributes);
-
PHP_FUNCTION(ldap_get_values);
PHP_FUNCTION(ldap_get_values_len);
-
PHP_FUNCTION(ber_free);
PHP_FUNCTION(ldap_get_dn);
PHP_FUNCTION(ldap_explode_dn);
PHP_FUNCTION(ldap_dn2ufn);
-
PHP_FUNCTION(ldap_add);
PHP_FUNCTION(ldap_delete);
-
PHP_FUNCTION(ldap_mod_add);
PHP_FUNCTION(ldap_mod_replace);
PHP_FUNCTION(ldap_mod_del);
-
PHP_FUNCTION(ldap_errno);
PHP_FUNCTION(ldap_err2str);
PHP_FUNCTION(ldap_error);
-
PHP_FUNCTION(ldap_compare);
-
PHP_FUNCTION(ldap_sort);
-#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
PHP_FUNCTION(ldap_get_option);
PHP_FUNCTION(ldap_set_option);
-PHP_FUNCTION(ldap_parse_result);
PHP_FUNCTION(ldap_first_reference);
PHP_FUNCTION(ldap_next_reference);
-PHP_FUNCTION(ldap_parse_reference);
PHP_FUNCTION(ldap_rename);
+#ifdef HAVE_LDAP_PARSE_RESULT
+PHP_FUNCTION(ldap_parse_result);
+#endif
+#ifdef HAVE_LDAP_PARSE_REFERENCE
+PHP_FUNCTION(ldap_parse_reference);
+#endif
#endif
#if LDAP_API_VERSION > 2000