]> granicus.if.org Git - php/commitdiff
check if return value of write() is -1 and abort upload in this case setting the...
authorAntony Dovgal <tony2001@php.net>
Fri, 14 Mar 2008 13:10:22 +0000 (13:10 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 14 Mar 2008 13:10:22 +0000 (13:10 +0000)
main/rfc1867.c

index e1975d84310ca5dd549ad66ab9091769f53225b9..b0e381b88a204c35158e05f259a84eac6933b0ab 100644 (file)
@@ -1263,7 +1263,13 @@ var_done:
                                } else if (blen > 0) {
                                        wlen = fwrite(buff, 1, blen, fp);
 
-                                       if (wlen < blen) {
+                                       if (wlen == -1) {
+                                               /* write failed */
+#if DEBUG_FILE_UPLOAD
+                                               sapi_module.sapi_error(E_NOTICE, "write() failed - %s", strerror(errno));
+#endif
+                                               cancel_upload = UPLOAD_ERROR_F;
+                                       } else if (wlen < blen) {
 #if DEBUG_FILE_UPLOAD
                                                sapi_module.sapi_error(E_NOTICE, "Only %d bytes were written, expected to write %d", wlen, blen);
 #endif
@@ -1712,7 +1718,13 @@ static SAPI_POST_HANDLER_FUNC(rfc1867_post_handler_legacy)
                                } else if (blen > 0) {
                                        wlen = write(fd, buff, blen);
                        
-                                       if (wlen < blen) {
+                                       if (wlen == -1) {
+                                               /* write failed */
+#if DEBUG_FILE_UPLOAD
+                                               sapi_module.sapi_error(E_NOTICE, "write() failed - %s", strerror(errno));
+#endif
+                                               cancel_upload = UPLOAD_ERROR_F;
+                                       } else if (wlen < blen) {
 #if DEBUG_FILE_UPLOAD
                                                sapi_module.sapi_error(E_NOTICE, "Only %d bytes were written, expected to write %d", wlen, blen);
 #endif