Skip to content
Merged
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
4 changes: 3 additions & 1 deletion ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,7 @@ PHP_FUNCTION(ldap_modify_batch)

/* for each modification */
zend_ulong modification_index = 0;
ZEND_HASH_FOREACH_NUM_KEY_VAL(modifications, modification_index, modification_zv) {
ZEND_HASH_FOREACH_VAL(modifications, modification_zv) {
ldap_mods[modification_index] = safe_emalloc(1, sizeof(LDAPMod), 0);

zval *attrib_zv = zend_hash_str_find_deref(Z_ARRVAL_P(modification_zv), LDAP_MODIFY_BATCH_ATTRIB, strlen(LDAP_MODIFY_BATCH_ATTRIB));
Expand Down Expand Up @@ -2822,6 +2822,8 @@ PHP_FUNCTION(ldap_modify_batch)
/* NULL-terminate values */
ldap_mods[modification_index]->mod_bvalues[num_modification_values] = NULL;
}

modification_index++;
} ZEND_HASH_FOREACH_END();

/* NULL-terminate modifications */
Expand Down
13 changes: 13 additions & 0 deletions ext/ldap/tests/ldap_modify_batch_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ $mods = array(
)
);

var_dump(ldap_modify_batch($link, "dc=my-domain,$base", $mods));

// high key with invalid attribute type
$mods = [
99999 => [
"attrib" => "weirdAttribute",
"modtype" => LDAP_MODIFY_BATCH_ADD,
"values" => ["value1"],
],
];
var_dump(ldap_modify_batch($link, "dc=my-domain,$base", $mods));
?>
--CLEAN--
Expand All @@ -81,3 +91,6 @@ bool(false)

Warning: ldap_modify_batch(): Batch Modify: Undefined attribute type in %s on line %d
bool(false)

Warning: ldap_modify_batch(): Batch Modify: Undefined attribute type in %s on line %d
bool(false)
7 changes: 5 additions & 2 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ typedef struct {
#endif
} zip_options;

/* Expects opts to be zero-initialized. */
static int php_zip_parse_options(HashTable *options, zip_options *opts)
/* {{{ */
{
zval *option;

/* default values */
memset(opts, 0, sizeof(zip_options));
opts->flags = ZIP_FL_OVERWRITE;
opts->comp_method = -1; /* -1 to not change default */
#ifdef HAVE_ENCRYPTION
Expand Down Expand Up @@ -1736,7 +1736,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
size_t path_len = 1;
zend_long glob_flags = 0;
HashTable *options = NULL;
zip_options opts;
zip_options opts = {0};
int found;
zend_string *pattern;

Expand Down Expand Up @@ -1800,6 +1800,9 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*

if (opts.add_path) {
if ((opts.add_path_len + file_stripped_len) > MAXPATHLEN) {
if (basename) {
zend_string_release_ex(basename, 0);
}
php_error_docref(NULL, E_WARNING, "Entry name too long (max: %d, %zd given)",
MAXPATHLEN - 1, (opts.add_path_len + file_stripped_len));
zend_array_destroy(Z_ARR_P(return_value));
Expand Down
22 changes: 22 additions & 0 deletions ext/zip/tests/addGlob_empty_options.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
addGlob with empty options
--EXTENSIONS--
zip
--FILE--
<?php

touch($file = __DIR__ . '/addglob_empty_options.zip');

$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->addGlob(__FILE__, 0, []);
var_dump($zip->statIndex(0)['name'] === __FILE__);
$zip->close();

?>
--CLEAN--
<?php
@unlink(__DIR__ . '/addglob_empty_options.zip');
?>
--EXPECT--
bool(true)
21 changes: 21 additions & 0 deletions ext/zip/tests/addGlob_too_long_add_path_option.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
addGlob with too long add_path option
--EXTENSIONS--
zip
--FILE--
<?php

touch($file = __DIR__ . '/addglob_too_long_add_path.zip');

$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->addGlob(__FILE__, 0, ['add_path' => str_repeat('A', PHP_MAXPATHLEN - 2)]);
$zip->close();

?>
--CLEAN--
<?php
@unlink(__DIR__ . '/addglob_too_long_add_path.zip');
?>
--EXPECTF--
Warning: ZipArchive::addGlob(): Entry name too long (max: %d, %d given) in %s on line %d
Loading