mirror of https://github.com/aria2/aria2
				
				
				
			2008-10-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that causes segmentation fault when accessing files which don't exist or are not included in --select-file option while validating chunk checksum. * src/MultiDiskAdaptor.ccpull/1/head
							parent
							
								
									837585e095
								
							
						
					
					
						commit
						cdb5796615
					
				| 
						 | 
				
			
			@ -1,3 +1,10 @@
 | 
			
		|||
2008-10-22 Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
			
		||||
 | 
			
		||||
	Fixed the bug that causes segmentation fault when accessing files which
 | 
			
		||||
	don't exist or are not included in --select-file option while
 | 
			
		||||
	validating chunk checksum.
 | 
			
		||||
	* src/MultiDiskAdaptor.cc
 | 
			
		||||
 | 
			
		||||
2008-10-20 Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
			
		||||
 | 
			
		||||
	Fixed compiler warning.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -372,6 +372,16 @@ findFirstDiskWriterEntry(const DiskWriterEntries& diskWriterEntries, off_t offse
 | 
			
		|||
  return first;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void throwOnDiskWriterNotOpened(const SharedHandle<DiskWriterEntry>& e,
 | 
			
		||||
				       off_t offset,
 | 
			
		||||
				       const std::string& topDirPath)
 | 
			
		||||
{
 | 
			
		||||
  throw DlAbortEx
 | 
			
		||||
    (StringFormat("DiskWriter for offset=%s, filename=%s is not opened.",
 | 
			
		||||
		  Util::itos(offset).c_str(),
 | 
			
		||||
		  e->getFilePath(topDirPath).c_str()).str());  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MultiDiskAdaptor::writeData(const unsigned char* data, size_t len,
 | 
			
		||||
				 off_t offset)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -384,6 +394,10 @@ void MultiDiskAdaptor::writeData(const unsigned char* data, size_t len,
 | 
			
		|||
 | 
			
		||||
    openIfNot(*i, &DiskWriterEntry::openFile, _cachedTopDirPath);
 | 
			
		||||
 | 
			
		||||
    if(!(*i)->isOpen()) {
 | 
			
		||||
      throwOnDiskWriterNotOpened(*i, offset+(len-rem), _cachedTopDirPath);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    (*i)->getDiskWriter()->writeData(data+(len-rem), writeLength, fileOffset);
 | 
			
		||||
    rem -= writeLength;
 | 
			
		||||
    fileOffset = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -405,6 +419,10 @@ ssize_t MultiDiskAdaptor::readData(unsigned char* data, size_t len, off_t offset
 | 
			
		|||
 | 
			
		||||
    openIfNot(*i, &DiskWriterEntry::openFile, _cachedTopDirPath);
 | 
			
		||||
 | 
			
		||||
    if(!(*i)->isOpen()) {
 | 
			
		||||
      throwOnDiskWriterNotOpened(*i, offset+(len-rem), _cachedTopDirPath);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    totalReadLength +=
 | 
			
		||||
      (*i)->getDiskWriter()->readData(data+(len-rem), readLength, fileOffset);
 | 
			
		||||
    rem -= readLength;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue