/* {{{ inifile_truncate */ static int inifile_truncate(inifile *dba, size_t size) { int res; if ((res=php_stream_truncate_set_size(dba->fp, size)) != 0) { php_error_docref(NULL, E_WARNING, "Error in ftruncate: %d", res); return FAILURE; } php_stream_seek(dba->fp, size, SEEK_SET); return SUCCESS; }
static HRESULT STDMETHODCALLTYPE stm_set_size(IStream *This, ULARGE_INTEGER libNewSize) { FETCH_STM(); if (libNewSize.HighPart) { return STG_E_INVALIDFUNCTION; } if (php_stream_truncate_supported(stm->stream)) { int ret = php_stream_truncate_set_size(stm->stream, (size_t)libNewSize.QuadPart); if (ret == 0) { return S_OK; } } return STG_E_INVALIDFUNCTION; }
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data) { if ((SG(post_max_size) > 0) && (SG(request_info).content_length > SG(post_max_size))) { php_error_docref(NULL, E_WARNING, "POST Content-Length of " ZEND_LONG_FMT " bytes exceeds the limit of " ZEND_LONG_FMT " bytes", SG(request_info).content_length, SG(post_max_size)); return; } SG(request_info).request_body = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir)); if (sapi_module.read_post) { size_t read_bytes; for (;;) { char buffer[SAPI_POST_BLOCK_SIZE]; read_bytes = sapi_read_post_block(buffer, SAPI_POST_BLOCK_SIZE); if (read_bytes > 0) { if (php_stream_write(SG(request_info).request_body, buffer, read_bytes) != read_bytes) { /* if parts of the stream can't be written, purge it completely */ php_stream_truncate_set_size(SG(request_info).request_body, 0); php_error_docref(NULL, E_WARNING, "POST data can't be buffered; all data discarded"); break; } } if ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) { php_error_docref(NULL, E_WARNING, "Actual POST length does not match Content-Length, and exceeds " ZEND_LONG_FMT " bytes", SG(post_max_size)); break; } if (read_bytes < SAPI_POST_BLOCK_SIZE) { /* done */ break; } } php_stream_rewind(SG(request_info).request_body); } }