Skip to content

Commit bb3f8ff

Browse files
committed
issue #2 replace zend_hash_find()
See https://github.com/the-kbA-team/php- pam/commit/156fa9f3666a3d85988d23515735839f67d24695#r30841135
1 parent b2de834 commit bb3f8ff

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

pam.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,11 @@ PHP_FUNCTION(pam_auth) {
261261
}
262262
hash_key = zend_string_init("_SERVER", sizeof ( "_SERVER"), 0);
263263
if (zend_hash_exists(&EG(symbol_table), hash_key)) {
264-
server = zend_hash_find_ind(&EG(symbol_table), hash_key);
265-
if (server != NULL) {
266-
hash_key = zend_string_init("REMOTE_ADDR", sizeof ( "REMOTE_ADDR"), 0);
267-
remote_addr = zend_hash_find_ind(Z_ARRVAL_P(server), hash_key);
268-
if (remote_addr != NULL && Z_TYPE_P(remote_addr)) {
269-
pam_set_item(pamh, PAM_RHOST, Z_STRVAL_P(remote_addr));
270-
}
264+
if ((server = zend_hash_str_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER")-1)) != NULL && Z_TYPE_P(server) == IS_ARRAY
265+
) {
266+
if ((remote_addr = zend_hash_str_find(Z_ARRVAL_P(server), "REMOTE_ADDR", sizeof("REMOTE_ADDR")-1)) != NULL && Z_TYPE_P(remote_addr) == IS_STRING) {
267+
pam_set_item(pamh, PAM_RHOST, Z_STRVAL_P(remote_addr));
268+
}
271269
}
272270
}
273271

0 commit comments

Comments
 (0)