From: Antony Dovgal Date: Fri, 14 Mar 2008 13:10:22 +0000 (+0000) Subject: check if return value of write() is -1 and abort upload in this case setting the... X-Git-Tag: RELEASE_2_0_0a1~139 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ec12a4794d1cfe7191705020d94419c5ba532df;p=php check if return value of write() is -1 and abort upload in this case setting the correct error status --- diff --git a/main/rfc1867.c b/main/rfc1867.c index e1975d8431..b0e381b88a 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -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