mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
[svn-r27320] Fix uninitialized memory write valgrind errors in trunk. Did this by modifying
metadata cache clients to clear unused memory in the buffer after serializing. Tested: ummon; jam, koala, ostrich (h5committest)
This commit is contained in:
parent
980db9e85b
commit
9804fed58f
@ -393,7 +393,7 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* H5B2__cache_hdr_serialize() */
|
||||
@ -698,6 +698,11 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
|
||||
#ifdef H5_CLEAR_MEMORY
|
||||
/* Clear rest of internal node */
|
||||
HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image));
|
||||
#endif /* H5_CLEAR_MEMORY */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5B2__cache_int_serialize() */
|
||||
@ -970,6 +975,11 @@ H5B2__cache_leaf_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED l
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
|
||||
#ifdef H5_CLEAR_MEMORY
|
||||
/* Clear rest of leaf node */
|
||||
HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image));
|
||||
#endif /* H5_CLEAR_MEMORY */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5B2__cache_leaf_serialize() */
|
||||
|
@ -338,10 +338,16 @@ H5B__serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len,
|
||||
/* Encode the final key */
|
||||
if(shared->type->encode(shared, image, native) < 0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
|
||||
image += shared->sizeof_rkey;
|
||||
} /* end if */
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)((const uint8_t *)image - (const uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
|
||||
#ifdef H5_CLEAR_MEMORY
|
||||
/* Clear rest of node */
|
||||
HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image));
|
||||
#endif /* H5_CLEAR_MEMORY */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
|
@ -488,7 +488,7 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */
|
||||
|
||||
@ -785,7 +785,7 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
CATCH
|
||||
|
||||
@ -1141,7 +1141,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */
|
||||
|
||||
@ -1494,7 +1494,7 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
CATCH
|
||||
|
||||
@ -1816,7 +1816,7 @@ H5EA__cache_dblk_page_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
CATCH
|
||||
|
||||
|
@ -407,7 +407,7 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */
|
||||
|
||||
@ -704,7 +704,7 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
CATCH
|
||||
|
||||
@ -976,7 +976,7 @@ H5FA__cache_dblk_page_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU
|
||||
UINT32ENCODE(image, metadata_chksum);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
CATCH
|
||||
|
||||
|
@ -716,7 +716,7 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU
|
||||
} /* end else */
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
@ -976,7 +976,7 @@ H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t len,
|
||||
image += 8 + drvinfo->len;
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
HDassert((size_t)(image - (uint8_t *)_image) == len);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
|
@ -316,8 +316,10 @@ H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len,
|
||||
if(H5G__ent_encode_vec(f, &image, sym->entry, sym->nsyms) < 0)
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't serialize")
|
||||
|
||||
#ifdef H5_CLEAR_MEMORY
|
||||
/* Clear rest of symbol table node */
|
||||
HDmemset(image, 0, sym->node_size - (size_t)(image - (uint8_t *)_image));
|
||||
HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image));
|
||||
#endif /* H5_CLEAR_MEMORY */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
|
@ -560,7 +560,19 @@ H5HL__cache_prefix_serialize(const H5F_t *f, void *_image, size_t len,
|
||||
|
||||
/* Copy the heap data block into the cache image */
|
||||
HDmemcpy(image, heap->dblk_image, heap->dblk_size);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) + heap->dblk_size == len);
|
||||
} /* end if */
|
||||
else {
|
||||
/* Sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= len);
|
||||
|
||||
#ifdef H5_CLEAR_MEMORY
|
||||
/* Clear rest of local heap */
|
||||
HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image));
|
||||
#endif /* H5_CLEAR_MEMORY */
|
||||
} /* end else */
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5HL__cache_prefix_serialize() */
|
||||
|
@ -675,13 +675,13 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t len,
|
||||
computed_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0);
|
||||
UINT32ENCODE(image, computed_chksum);
|
||||
|
||||
/* sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= list->header->list_size);
|
||||
|
||||
#ifdef H5_CLEAR_MEMORY
|
||||
HDmemset(image, 0, (list->header->list_size - (size_t)(image - (uint8_t *)_image)));
|
||||
#endif /* H5_CLEAR_MEMORY */
|
||||
|
||||
/* sanity check */
|
||||
HDassert((size_t)(image - (uint8_t *)_image) <= list->header->list_size);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5SM__cache_list_serialize() */
|
||||
|
Loading…
Reference in New Issue
Block a user