summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-03-04 19:26:47 +0100
committerAnatol Belski <ab@php.net>2015-03-04 19:27:45 +0100
commit01ccfb7cc91e652a6c93ec8c62817d4ed95bbc19 (patch)
treed65f0c603c2e77c0f12e7817da7c71c5d6281c88 /win32
parentff039c3c6d16346d53b971885ff7becddb993873 (diff)
downloadphp-git-01ccfb7cc91e652a6c93ec8c62817d4ed95bbc19.tar.gz
fix ini registry handling
Diffstat (limited to 'win32')
-rw-r--r--win32/registry.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/win32/registry.c b/win32/registry.c
index 3d4496094b..30278fa0b2 100644
--- a/win32/registry.c
+++ b/win32/registry.c
@@ -70,13 +70,18 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_
char *name = (char*)emalloc(max_name+1);
char *value = (char*)emalloc(max_value+1);
DWORD name_len, type, value_len;
- zval data;
for (i = 0; i < values; i++) {
name_len = max_name+1;
value_len = max_value+1;
+
+ memset(name, '\0', max_name+1);
+ memset(value, '\0', max_value+1);
+
if (RegEnumValue(key, i, name, &name_len, NULL, &type, value, &value_len) == ERROR_SUCCESS) {
if ((type == REG_SZ) || (type == REG_EXPAND_SZ)) {
+ zval data;
+
if (!ht) {
ht = (HashTable*)malloc(sizeof(HashTable));
if (!ht) {
@@ -84,6 +89,7 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_
}
zend_hash_init(ht, 0, NULL, ZVAL_INTERNAL_PTR_DTOR, 1);
}
+ ZVAL_PSTRINGL(&data, value, value_len-1);
zend_hash_str_update(ht, name, name_len, &data);
}
}
@@ -91,14 +97,14 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_
if (ht) {
if (parent_ht) {
zend_string *index;
- ulong num;
+ zend_ulong num;
zval *tmpdata;
ZEND_HASH_FOREACH_KEY_VAL(parent_ht, num, index, tmpdata) {
zend_hash_add(ht, index, tmpdata);
} ZEND_HASH_FOREACH_END();
}
- zend_hash_str_update_mem(directories, path, path_len + 1, &ht, sizeof(HashTable*));
+ zend_hash_str_update_mem(directories, path, path_len, ht, sizeof(HashTable));
ret = 1;
}
@@ -148,9 +154,9 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_
static void delete_internal_hashtable(zval *zv)
{
- void *data = Z_PTR_P(zv);
- zend_hash_destroy(*(HashTable**)data);
- free(*(HashTable**)data);
+ HashTable *ht = (HashTable *)Z_PTR_P(zv);
+ zend_hash_destroy(ht);
+ free(ht);
}
#define RegNotifyFlags (REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET)
@@ -159,7 +165,6 @@ void UpdateIniFromRegistry(char *path)
{
char *p, *orig_path;
int path_len;
- HashTable *pht;
if(!path) {
return;
@@ -234,15 +239,16 @@ void UpdateIniFromRegistry(char *path)
path_len++;
}
zend_str_tolower(path, path_len);
+
while (path_len >= 0) {
- pht = (HashTable *)zend_hash_str_find_ptr(PW32G(registry_directories), path, path_len+1);
- if (pht != NULL) {
- HashTable *ht = pht;
+ HashTable *ht = (HashTable *)zend_hash_str_find_ptr(PW32G(registry_directories), path, path_len);
+
+ if (ht != NULL) {
zend_string *index;
zval *data;
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, index, data) {
- zend_alter_ini_entry(index, Z_STR_P(data), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
+ zend_alter_ini_entry(index, Z_STR_P(data), PHP_INI_USER, PHP_INI_STAGE_ACTIVATE);
} ZEND_HASH_FOREACH_END();
}