r88244 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88243‎ | r88244 | r88245 >
Date:15:40, 16 May 2011
Author:j
Status:deferred
Tags:
Comment:
check that chunk offset matches file size before appending to file
Modified paths:
  • /trunk/extensions/ResumableUpload/ResumableUploadHandler.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ResumableUpload/ResumableUploadHandler.php
@@ -66,9 +66,10 @@
6767 *
6868 * @return mixed True if there was no error, otherwise an error description suitable for passing to dieUsage()
6969 */
70 - public function initialize( $done, $filename, $sessionKey, $path, $chunkSize, $sessionData ) {
 70+ public function initialize( $done, $chunkOffset, $filename, $sessionKey, $path, $chunkSize, $sessionData ) {
7171 if( $filename ) $this->mDesiredDestName = $filename;
7272 $this->mTempPath = $path;
 73+ $this->mChunkOffset = $chunkOffset;
7374
7475 if ( $sessionKey !== null ) {
7576 $status = $this->initFromSessionKey( $sessionKey, $sessionData, $chunkSize );
@@ -144,11 +145,14 @@
145146 }
146147
147148 if ( $this->getRealPath( $this->repoPath ) ) {
148 - $this->status = $this->appendToUploadFile( $this->repoPath, $this->mTempPath );
 149+ if ( $this->getSize( $this->repoPath ) == $this->mChunkOffset ) {
 150+ $this->status = $this->appendToUploadFile( $this->repoPath, $this->mTempPath );
 151+ if ( $this->mFileSize > $wgMaxUploadSize )
 152+ $this->status = Status::newFatal( 'largefileserver' );
 153+ } else {
 154+ $this->status = Status::newFatal( 'failed, chunk offset does not match file' );
 155+ }
149156
150 - if ( $this->mFileSize > $wgMaxUploadSize )
151 - $this->status = Status::newFatal( 'largefileserver' );
152 -
153157 } else {
154158 $this->status = Status::newFatal( 'filenotfound', $this->repoPath );
155159 }
@@ -163,4 +167,4 @@
164168 $this->appendChunk();
165169 $this->mTempPath = $this->getRealPath( $this->repoPath );
166170 }
167 -}
\ No newline at end of file
 171+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r88245also pass offset to initialize, was missing in 88244j15:44, 16 May 2011

Status & tagging log