com php-src: Fix #73100: session_destroy null dereference in ps_files_path_create: NEWS ext/session/mod _files.c ext/session/tests/bug73100.phpt
| From: | Christoph Michael Becker | Date: | Fri, 16 Sep 2016 21:41:10 +0000 |
| Subject: | com php-src: Fix #73100: session_destroy null dereference in ps_files_path_create: NEWS ext/session/mod _files.c ext/session/tests/bug73100.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94576@lists.php.net to get a copy of this message | ||
Commit: 66826730702d3ed3d6d45320ad1276977e67bb9e
Author: Christoph M. Becker <cmbecker69@gmx.de> Fri, 16 Sep 2016 23:41:10 +0200
Parents: 01c7c6b152c4aaf91522d94933853f8bfe7e920d
Branches: PHP-5.6 PHP-7..0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=66826730702d3ed3d6d45320ad1276977e67bb9e
Log:
Fix #73100: session_destroy null dereference in ps_files_path_create
Bugs:
https://bugs.php.net/73100
Changed paths:
M NEWS
M ext/session/mod_files.c
A ext/session/tests/bug73100.phpt
Diff:
diff --git a/NEWS b/NEWS
index bdd72bf..21fcc66 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,8 @@ PHP NEWS
- Session:
. Fixed bug #68015 (Session does not report invalid uid for files save handler).
(Yasuo)
+ . Fixed bug #73100 (session_destroy null dereference in ps_files_path_create)..
+ (cmb)
- Stream:
. Fixed bug #73069 (readfile() mangles files larger than 2G). (Laruence)
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 80eb658..5c69ae3 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -79,7 +79,7 @@ static char *ps_files_path_create(char *buf, size_t buflen, ps_files *data, cons
int n;
key_len = strlen(key);
- if (key_len <= data->dirdepth ||
+ if (!data || key_len <= data->dirdepth ||
buflen < (strlen(data->basedir) + 2 * data->dirdepth + key_len + 5 +
sizeof(FILE_PREFIX))) {
return NULL;
}
diff --git a/ext/session/tests/bug73100.phpt b/ext/session/tests/bug73100.phpt
new file mode 100644
index 0000000..0503541
--- /dev/null
+++ b/ext/session/tests/bug73100.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #73100 (session_destroy null dereference in ps_files_path_create)
+--SKIPIF--
+<?php
+if (!extension_loaded('session')) die('skip session extension not available');
+?>
+--FILE--
+<?php
+ob_start();
+var_dump(session_start());
+session_module_name("user");
+var_dump(session_destroy());
+?>
+===DONE===
+--EXPECTF--
+bool(true)
+
+Warning: session_module_name(): A session is active. You cannot change the session module's
ini settings at this time in %s on line %d
+
+Warning: session_destroy(): Session object destruction failed in %s on line %d
+bool(false)
+===DONE===