com php-src: improved file size computation in stat(): Zend/zend_virtual_cwd.c
| From: | Anatol Belski | Date: | Thu, 02 Oct 2014 10:18:02 +0000 |
| Subject: | com php-src: improved file size computation in stat(): Zend/zend_virtual_cwd.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82051@lists.php.net to get a copy of this message | ||
Commit: c41fbcfb4c68392dc7c561b81ad0f6c25672034f
Author: Anatol Belski <ab@php.net> Thu, 2 Oct 2014 12:15:34 +0200
Parents: ccb24caa6d2e8bb0a8f3959543173a1f65c84b2d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c41fbcfb4c68392dc7c561b81ad0f6c25672034f
Log:
improved file size computation in stat()
On 32 bit it's still overwlowing, so nothing is changed there. But
the usage of LARGE_INTEGER instead of bit shifting is a better way
to go.
Changed paths:
M Zend/zend_virtual_cwd.c
Diff:
diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
index b061d5a..01a91ca 100644
--- a/Zend/zend_virtual_cwd.c
+++ b/Zend/zend_virtual_cwd.c
@@ -294,7 +294,7 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{{ */
{
WIN32_FILE_ATTRIBUTE_DATA data;
- __int64 t;
+ LARGE_INTEGER t;
const size_t path_len = strlen(path);
ALLOCA_FLAG(use_heap_large);
@@ -393,10 +393,11 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /*
{{
}
buf->st_nlink = 1;
- t = data.nFileSizeHigh;
- t = t << 32;
- t |= data.nFileSizeLow;
- buf->st_size = t;
+ t.HighPart = data.nFileSizeHigh;
+ t.LowPart = data.nFileSizeLow;
+ /* It's an overflow on 32 bit, however it won't fix as long
+ as zend_long is 32 bit. */
+ buf->st_size = (zend_long)t.QuadPart;
buf->st_atime = FileTimeToUnixTime(&data.ftLastAccessTime);
buf->st_ctime = FileTimeToUnixTime(&data.ftCreationTime);
buf->st_mtime = FileTimeToUnixTime(&data.ftLastWriteTime);