com php-src: fix possible out of bounds buffer access: Zend/zend_virtual_cwd.c

[email protected] (Anatol Belski)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    feeb35e438db36f08bb82d493b11d4211201f23c
Author:    Anatol Belski <[email protected]>         Mon, 3 Apr 2017 15:20:32 +0200
Parents:   670041b60ec25e822564d337bae96e82e8d9ac89
Branches:  PHP-7.0 PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=feeb35e438db36f08bb82d493b11d4211201f23c

Log:
fix possible out of bounds buffer access

Changed paths:
  M  Zend/zend_virtual_cwd.c


Diff:
diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
index ca19802..8009f2f 100644
--- a/Zend/zend_virtual_cwd.c
+++ b/Zend/zend_virtual_cwd.c
@@ -380,7 +380,7 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
 	if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
 		size_t len = strlen(path);
 
-		if (path[len-4] == '.') {
+		if (len >= 4 && path[len-4] == '.') {
 			if (_memicmp(path+len-3, "exe", 3) == 0 ||
 				_memicmp(path+len-3, "com", 3) == 0 ||
 				_memicmp(path+len-3, "bat", 3) == 0 ||
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.