Skip to content
Snippets Groups Projects
Commit cef807d0 authored by Joachim Metz's avatar Joachim Metz
Browse files

Fix for segfault in img_io when underlying img info object returns false information.

parent 556ac8a9
No related branches found
No related tags found
No related merge requests found
......@@ -208,16 +208,18 @@ tsk_img_read(TSK_IMG_INFO * a_img_info, TSK_OFF_T a_off,
// Determine the offset relative to the start of the cached data.
a_rel_off = a_off - a_img_info->cache_off[cache_next];
// Make sure we were able to read sufficient data into the cache.
if(rel_off > (TSK_OFF_T) read_count) {
len2 = 0;
}
// Make sure not to copy more than is available in the cache.
if( ( a_rel_off + (TSK_OFF_T) len2 ) > (TSK_OFF_T) read_count ) {
len2 = (size_t) ( read_count - a_rel_off );
else if ((rel_off + (TSK_OFF_T) len2) > (TSK_OFF_T) read_count) {
len2 = (size_t) (read_count - rel_off);
}
// Only copy data when we have something to copy.
if(len2 > 0) {
memcpy(a_buf, &(a_img_info->cache[cache_next][rel_off]), len2);
}
memcpy(
a_buf,
&( a_img_info->cache[ cache_next ][ a_rel_off ] ),
len2 );
read_count = (ssize_t) len2;
}
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment