com php-src: phpdbg: couple of network function return checks. Possible overflow when copy the socket_path configuration.: ex t/session/mod_files.c
sapi/phpdbg/phpdbg_wait.c
| From: | Stanislav Malyshev | Date: | Mon, 05 Sep 2016 06:18:51 +0000 |
| Subject: | com php-src: phpdbg: couple of network function return checks. Possible overflow when copy the socket_path configuration.: ex t/session/mod_files.c sapi/phpdbg/phpdbg_wait.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94298@lists.php.net to get a copy of this message | ||
Commit: 19350b6b7398edc9cc92e169aaf717585aa6ff11
Author: David Carlier <devnexen@gmail.com> Tue, 28 Jun 2016 07:48:58 +0100
Committer: Stanislav Malyshev <stas@php.net> Sun, 4 Sep 2016 23:18:51 -0700
Parents: a2fdf0f4135f5a29e613c1c6c53d378dc6ff7bed
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=19350b6b7398edc9cc92e169aaf717585aa6ff11
Log:
phpdbg: couple of network function return checks. Possible
overflow when copy the socket_path configuration.
Changed paths:
M ext/session/mod_files.c
M sapi/phpdbg/phpdbg_wait.c
Diff:
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 64a6c47..521fadd 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -296,6 +296,7 @@ static int ps_files_cleanup_dir(const char *dirname, zend_long maxlifetime)
if (dirname_len >= MAXPATHLEN) {
php_error_docref(NULL, E_NOTICE, "ps_files_cleanup_dir: dirname(%s) is too long",
dirname);
+ closedir(dir);
return (0);
}
diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c
index c7dcd4f..5ef29e8 100644
--- a/sapi/phpdbg/phpdbg_wait.c
+++ b/sapi/phpdbg/phpdbg_wait.c
@@ -248,8 +248,10 @@ void phpdbg_webdata_decompress(char *msg, int len) {
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
while (extension) {
extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos);
+ if (extension == NULL){
+ break;
+ }
- /* php_serach_array() body should be in some ZEND_API function.... */
ZEND_HASH_FOREACH_STR_KEY_PTR(Z_ARRVAL_P(zvp), strkey, name) {
if (Z_TYPE_P(name) == IS_STRING && !zend_binary_strcmp(extension->name,
strlen(extension->name), Z_STRVAL_P(name), Z_STRLEN_P(name))) {
break;
@@ -344,9 +346,16 @@ PHPDBG_COMMAND(wait) /* {{{ */
if (PHPDBG_G(socket_server_fd) == -1) {
int len;
PHPDBG_G(socket_server_fd) = sl = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sl == -1) {
+ phpdbg_error("wait", "type=\"nosocket\"
import=\"fail\"", "Unable to open a socket to UNIX domain socket at %s defined
by phpdbg.path ini setting", PHPDBG_G(socket_path));
+ return FAILURE;
+ }
local.sun_family = AF_UNIX;
- strcpy(local.sun_path, PHPDBG_G(socket_path));
+ if (strlcpy(local.sun_path, PHPDBG_G(socket_path), sizeof(local.sun_path)) >
sizeof(local.sun_path)) {
+ phpdbg_error("wait", "type=\"nosocket\"
import=\"fail\"", "Socket at %s defined by phpdbg.path ini setting is too
long", PHPDBG_G(socket_path));
+ return FAILURE;
+ }
len = strlen(local.sun_path) + sizeof(local.sun_family);
if (bind(sl, (struct sockaddr *)&local, len) == -1) {
phpdbg_error("wait", "type=\"nosocket\"
import=\"fail\"", "Unable to connect to UNIX domain socket at %s defined by
phpdbg.path ini setting", PHPDBG_G(socket_path));
@@ -362,6 +371,11 @@ PHPDBG_COMMAND(wait) /* {{{ */
rlen = sizeof(remote);
sr = accept(sl, (struct sockaddr *) &remote, (socklen_t *) &rlen);
+ if (sr == -1) {
+ phpdbg_error("wait", "type=\"nosocket\" import=\"fail\"",
"Unable to create a connection to UNIX domain socket at %s defined by phpdbg.path ini
setting", PHPDBG_G(socket_path));
+ close(PHPDBG_G(socket_server_fd));
+ return FAILURE;
+ }
char msglen[5];
int recvd = 4;