Skip to content

Fixed bug #63126, imap_open: DISABLE_AUTHENTICATOR ignores array #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/imap/php_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (zend_hash_index_find(Z_ARRVAL_PP(disabled_auth_method), i, (void **) &z_auth_method) == SUCCESS) {
if (Z_TYPE_PP(z_auth_method) == IS_STRING) {
if (Z_STRLEN_PP(z_auth_method) > 1) {
mail_parameters (NIL, DISABLE_AUTHENTICATOR, (void *)Z_STRVAL_PP(disabled_auth_method));
mail_parameters (NIL, DISABLE_AUTHENTICATOR, (void *)Z_STRVAL_PP(z_auth_method));
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument, expect string or array of strings");
Expand Down
52 changes: 52 additions & 0 deletions ext/imap/tests/bug63126.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--TEST--
imap_open() DISABLE_AUTHENTICATOR ignores array param
--SKIPIF--
<?php
extension_loaded('imap') or die('skip imap extension not available in this build');

require_once(dirname(__FILE__).'/imap_include.inc');

$in = imap_open($default_mailbox, $username, $password, OP_HALFOPEN, 1);
if (!$in) {
die("skip could not connect to mailbox $default_mailbox");
}
$kerberos = false;
if (is_array($errors = imap_errors())) {
foreach ($errors as $err) {
if (strstr($err, 'GSSAPI') || strstr($err, 'Kerberos')) {
$kerberos = true;
}
}
}
if (!$kerberos) {
die("skip need a GSSAPI/Kerberos aware server");
}
?>
--FILE--
<?php
$tests = array(
'Array' => array('DISABLE_AUTHENTICATOR' => array('GSSAPI','NTLM')),
'String' => array('DISABLE_AUTHENTICATOR' => 'GSSAPI'),
);
require_once(dirname(__FILE__).'/imap_include.inc');
foreach ($tests as $name => $testparams) {
echo "Test for $name\n";
$in = imap_open($default_mailbox, $username, $password, OP_HALFOPEN, 1, $testparams);
if ($in) {
if (is_array($errors = imap_errors())) {
foreach ($errors as $err) {
if (strstr($err, 'GSSAPI') || strstr($err, 'Kerberos')) {
echo "$err\n";
}
}
}
} else {
echo "Can't connect\n";
}
}
echo "Done\n";
?>
--EXPECTF--
Test for Array
Test for String
Done