mirror of https://github.com/aria2/aria2
				
				
				
			Check sum of file length does not exceed INT64_MAX
With BitTorrent or Metalink (metaurl), one RequestGroup can contain multiple files. In this change, ensure that the sum of thoese files must be equal or less than INT64_MAX.pull/25/merge
							parent
							
								
									860f4dd06a
								
							
						
					
					
						commit
						4b57106a17
					
				|  | @ -57,6 +57,7 @@ | ||||||
| #include "download_helper.h" | #include "download_helper.h" | ||||||
| #include "fmt.h" | #include "fmt.h" | ||||||
| #include "SegList.h" | #include "SegList.h" | ||||||
|  | #include "DownloadFailureException.h" | ||||||
| #ifdef ENABLE_BITTORRENT | #ifdef ENABLE_BITTORRENT | ||||||
| # include "BtDependency.h" | # include "BtDependency.h" | ||||||
| # include "download_helper.h" | # include "download_helper.h" | ||||||
|  | @ -313,6 +314,10 @@ Metalink2RequestGroup::createRequestGroup | ||||||
|         } |         } | ||||||
|         fe->setOriginalName((*i)->metaurls[0]->name); |         fe->setOriginalName((*i)->metaurls[0]->name); | ||||||
|         fileEntries.push_back(fe); |         fileEntries.push_back(fe); | ||||||
|  |         if(offset > | ||||||
|  |            std::numeric_limits<int64_t>::max() - (*i)->file->getLength()) { | ||||||
|  |           throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, offset)); | ||||||
|  |         } | ||||||
|         offset += (*i)->file->getLength(); |         offset += (*i)->file->getLength(); | ||||||
|       } |       } | ||||||
|       dctx->setFileEntries(fileEntries.begin(), fileEntries.end()); |       dctx->setFileEntries(fileEntries.begin(), fileEntries.end()); | ||||||
|  |  | ||||||
|  | @ -248,6 +248,9 @@ void extractFileEntries | ||||||
|         throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH.c_str()), |         throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH.c_str()), | ||||||
|                            error_code::BITTORRENT_PARSE_ERROR); |                            error_code::BITTORRENT_PARSE_ERROR); | ||||||
|       } |       } | ||||||
|  |       if(length > std::numeric_limits<int64_t>::max() - fileLengthData->i()) { | ||||||
|  |         throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, length)); | ||||||
|  |       } | ||||||
|       length += fileLengthData->i(); |       length += fileLengthData->i(); | ||||||
|       if(fileLengthData->i() > std::numeric_limits<off_t>::max()) { |       if(fileLengthData->i() > std::numeric_limits<off_t>::max()) { | ||||||
|         throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, length)); |         throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, length)); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Tatsuhiro Tsujikawa
						Tatsuhiro Tsujikawa