cvs: php-src /main/streams plain_wrapper.c
| From: | Dmitry Stogov | Date: | Wed, 18 Apr 2007 14:23:35 +0000 |
| Subject: | cvs: php-src /main/streams plain_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-43970@lists.php.net to get a copy of this message | ||
dmitry Wed Apr 18 14:23:35 2007 UTC
Modified files:
/php-src/main/streams plain_wrapper.c
Log:
Fixed crash on win32 in case of negative size
http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.86&r2=1.87&diff_format=u
Index: php-src/main/streams/plain_wrapper.c
diff -u php-src/main/streams/plain_wrapper.c:1.86 php-src/main/streams/plain_wrapper.c:1.87
--- php-src/main/streams/plain_wrapper.c:1.86 Wed Apr 18 13:53:32 2007
+++ php-src/main/streams/plain_wrapper.c Wed Apr 18 14:23:35 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: plain_wrapper.c,v 1.86 2007/04/18 13:53:32 dmitry Exp $ */
+/* $Id: plain_wrapper.c,v 1.87 2007/04/18 14:23:35 dmitry Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -777,8 +777,13 @@
case PHP_STREAM_TRUNCATE_SUPPORTED:
return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
- case PHP_STREAM_TRUNCATE_SET_SIZE:
- return ftruncate(fd, *(ptrdiff_t*)ptrparam) == 0 ? PHP_STREAM_OPTION_RETURN_OK :
PHP_STREAM_OPTION_RETURN_ERR;
+ case PHP_STREAM_TRUNCATE_SET_SIZE: {
+ ptrdiff_t new_size = *(ptrdiff_t*)ptrparam;
+ if (new_size < 0) {
+ return PHP_STREAM_OPTION_RETURN_ERR;
+ }
+ return ftruncate(fd, new_size) == 0 ? PHP_STREAM_OPTION_RETURN_OK :
PHP_STREAM_OPTION_RETURN_ERR;
+ }
}
default: