added some extra checks for buffer overrun in disk_io_thread
This commit is contained in:
parent
77481c24a7
commit
192ce4b463
|
@ -111,6 +111,10 @@ namespace libtorrent
|
||||||
// memory pool for read and write operations
|
// memory pool for read and write operations
|
||||||
boost::pool<> m_pool;
|
boost::pool<> m_pool;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
int m_block_size;
|
||||||
|
#endif
|
||||||
|
|
||||||
// thread for performing blocking disk io operations
|
// thread for performing blocking disk io operations
|
||||||
boost::thread m_disk_io_thread;
|
boost::thread m_disk_io_thread;
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,6 +41,9 @@ namespace libtorrent
|
||||||
: m_abort(false)
|
: m_abort(false)
|
||||||
, m_queue_buffer_size(0)
|
, m_queue_buffer_size(0)
|
||||||
, m_pool(block_size)
|
, m_pool(block_size)
|
||||||
|
#ifndef NDEBUG
|
||||||
|
, m_block_size(block_size)
|
||||||
|
#endif
|
||||||
, m_disk_io_thread(boost::ref(*this))
|
, m_disk_io_thread(boost::ref(*this))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -192,6 +195,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
assert(j.buffer_size <= m_block_size);
|
||||||
ret = j.storage->read_impl(j.buffer, j.piece, j.offset
|
ret = j.storage->read_impl(j.buffer, j.piece, j.offset
|
||||||
, j.buffer_size);
|
, j.buffer_size);
|
||||||
|
|
||||||
|
@ -201,6 +205,7 @@ namespace libtorrent
|
||||||
break;
|
break;
|
||||||
case disk_io_job::write:
|
case disk_io_job::write:
|
||||||
assert(j.buffer);
|
assert(j.buffer);
|
||||||
|
assert(j.buffer_size <= m_block_size);
|
||||||
j.storage->write_impl(j.buffer, j.piece, j.offset
|
j.storage->write_impl(j.buffer, j.piece, j.offset
|
||||||
, j.buffer_size);
|
, j.buffer_size);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue