php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #34750
Patch double_filesize.patch revision 2010-08-23 20:06 UTC by dominic dot benson at thirdlight dot com

Patch double_filesize.patch for *General Issues Bug #34750

Patch version 2010-08-23 20:06 UTC

Return to Bug #34750 | Download this patch
Patch Revisions:

Developer: dominic.benson@thirdlight.com

diff -rupN php-5.3.3/ext/standard/filestat.c php-5.3.3-patch2/ext/standard/filestat.c
--- php-5.3.3/ext/standard/filestat.c	2010-01-03 09:23:27.000000000 +0000
+++ php-5.3.3-patch2/ext/standard/filestat.c	2010-08-05 12:35:07.269067561 +0100
@@ -893,7 +893,16 @@ PHPAPI void php_stat(const char *filenam
 	case FS_INODE:
 		RETURN_LONG((long)ssb.sb.st_ino);
 	case FS_SIZE:
-		RETURN_LONG((long)ssb.sb.st_size);
+		if(ssb.sb.st_size < LONG_MAX) {
+			RETURN_LONG((long)ssb.sb.st_size);
+		}
+		if(ssb.sb.st_size < 9007199254740992LL) {
+			// 2^53, max exact value on double
+                        RETURN_DOUBLE((double)ssb.sb.st_size);
+                }
+		// Out of safe range
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Size of file %s exceeds safe range for double", filename);
+		RETURN_FALSE;
 	case FS_OWNER:
 		RETURN_LONG((long)ssb.sb.st_uid);
 	case FS_GROUP:
@@ -1027,7 +1036,7 @@ FileFunction(PHP_FN(fileperms), FS_PERMS
 FileFunction(PHP_FN(fileinode), FS_INODE)
 /* }}} */
 
-/* {{{ proto int filesize(string filename)
+/* {{{ proto mixed filesize(string filename)
    Get file size */
 FileFunction(PHP_FN(filesize), FS_SIZE)
 /* }}} */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 09:01:27 2024 UTC