dmitry          Wed Apr 18 14:23:06 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /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.52.2.6.2.20&r2=1.52.2.6.2.21&diff_format=u
Index: php-src/main/streams/plain_wrapper.c
diff -u php-src/main/streams/plain_wrapper.c:1.52.2.6.2.20 
php-src/main/streams/plain_wrapper.c:1.52.2.6.2.21
--- php-src/main/streams/plain_wrapper.c:1.52.2.6.2.20  Wed Apr 18 13:53:19 2007
+++ php-src/main/streams/plain_wrapper.c        Wed Apr 18 14:23:06 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: plain_wrapper.c,v 1.52.2.6.2.20 2007/04/18 13:53:19 dmitry Exp $ */
+/* $Id: plain_wrapper.c,v 1.52.2.6.2.21 2007/04/18 14:23:06 dmitry Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -773,8 +773,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:

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to