[prev in list] [next in list] [prev in thread] [next in thread]
List: php-cvs
Subject: [PHP-CVS] com php-src: Fix bug #72940 properly. Reduce needless branches: ext/session/session.c
From: Yasuo Ohgaki <yohgaki () php ! net>
Date: 2016-08-31 22:47:13
Message-ID: php-mail-520764be724e666b40390b77999460131522179554 () git ! php ! net
[Download RAW message or body]
Commit: cc797d4fc3e6de1a21cbe91f810767cc491c7696
Author: Yasuo Ohgaki <yohgaki@php.net> Thu, 1 Sep 2016 07:47:04 +0900
Parents: f93fd8ce3278923dce16b241aebe428a6b9aa79d
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cc797d4fc3e6de1a21cbe91f810767cc491c7696
Log:
Fix bug #72940 properly. Reduce needless branches
Bugs:
https://bugs.php.net/72940
Changed paths:
M ext/session/session.c
Diff:
diff --git a/ext/session/session.c b/ext/session/session.c
index a47e78c..4a61ae9 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -1636,50 +1636,47 @@ PHPAPI void php_session_start(void) /* {{{ */
PS(define_sid) = 0;
}
}
-
- if (PS(define_sid) && !PS(id) && (data = zend_hash_str_find(&EG(symbol_table), \
"_GET", sizeof("_GET") - 1))) {
- ZVAL_DEREF(data);
- if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), \
PS(session_name), lensess))) {
- ppid2sid(ppid);
+ /* Initilize session ID from non cookie values */
+ if (!PS(use_only_cookies)) {
+ if (!PS(id) && (data = zend_hash_str_find(&EG(symbol_table), "_GET", \
sizeof("_GET") - 1))) { + ZVAL_DEREF(data);
+ if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), \
PS(session_name), lensess))) { + ppid2sid(ppid);
+ }
}
- }
-
- if (PS(define_sid) && !PS(id) && (data = zend_hash_str_find(&EG(symbol_table), \
"_POST", sizeof("_POST") - 1))) {
- ZVAL_DEREF(data);
- if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), \
PS(session_name), lensess))) {
- ppid2sid(ppid);
+ if (!PS(id) && (data = zend_hash_str_find(&EG(symbol_table), "_POST", \
sizeof("_POST") - 1))) { + ZVAL_DEREF(data);
+ if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), \
PS(session_name), lensess))) { + ppid2sid(ppid);
+ }
}
- }
-
- /* Check the REQUEST_URI symbol for a string of the form
- * '<session-name>=<session-id>' to allow URLs of the form
- * http://yoursite/<session-name>=<session-id>/script.php */
- if (PS(define_sid) && !PS(id) &&
- zend_is_auto_global_str("_SERVER", sizeof("_SERVER") - 1) == SUCCESS &&
- (data = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), \
"REQUEST_URI", sizeof("REQUEST_URI") - 1)) &&
- Z_TYPE_P(data) == IS_STRING &&
- (p = strstr(Z_STRVAL_P(data), PS(session_name))) &&
- p[lensess] == '='
- ) {
- char *q;
- p += lensess + 1;
- if ((q = strpbrk(p, "/?\\"))) {
- PS(id) = zend_string_init(p, q - p, 0);
+ /* Check the REQUEST_URI symbol for a string of the form
+ * '<session-name>=<session-id>' to allow URLs of the form
+ * http://yoursite/<session-name>=<session-id>/script.php */
+ if (!PS(id) && zend_is_auto_global_str("_SERVER", sizeof("_SERVER") - 1) == \
SUCCESS && + (data = \
zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "REQUEST_URI", \
sizeof("REQUEST_URI") - 1)) && + Z_TYPE_P(data) == IS_STRING &&
+ (p = strstr(Z_STRVAL_P(data), PS(session_name))) &&
+ p[lensess] == '='
+ ) {
+ char *q;
+ p += lensess + 1;
+ if ((q = strpbrk(p, "/?\\"))) {
+ PS(id) = zend_string_init(p, q - p, 0);
+ }
+ }
+ /* Check whether the current request was referred to by
+ * an external site which invalidates the previously found id. */
+ if (PS(id) && PS(extern_referer_chk)[0] != '\0' &&
+ !Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER]) &&
+ (data = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), \
"HTTP_REFERER", sizeof("HTTP_REFERER") - 1)) && + Z_TYPE_P(data) == IS_STRING &&
+ Z_STRLEN_P(data) != 0 &&
+ strstr(Z_STRVAL_P(data), PS(extern_referer_chk)) == NULL
+ ) {
+ zend_string_release(PS(id));
+ PS(id) = NULL;
}
- }
-
- /* Check whether the current request was referred to by
- * an external site which invalidates the previously found id. */
- if (PS(define_sid) && PS(id) &&
- PS(extern_referer_chk)[0] != '\0' &&
- !Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER]) &&
- (data = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), \
"HTTP_REFERER", sizeof("HTTP_REFERER") - 1)) &&
- Z_TYPE_P(data) == IS_STRING &&
- Z_STRLEN_P(data) != 0 &&
- strstr(Z_STRVAL_P(data), PS(extern_referer_chk)) == NULL
- ) {
- zend_string_release(PS(id));
- PS(id) = NULL;
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic