2
0
mirror of https://github.com/HDFGroup/hdf5.git synced 2025-04-24 17:51:25 +08:00

malloc --> calloc in H5B cache entry ()

oss-fuzz occasionally complains about intermittent undefined behavior
when when Boolean variables in H5C_cache_entry_t (like is_protected)
are set to values other than 0 or 1 when parsing fuzzed files. Using
calloc() to iniitialize the H5B_t struct (like other metadata already
does) should fix this.
This commit is contained in:
Dana Robinson 2024-10-31 07:38:50 -07:00 committed by GitHub
parent 8f0cdce2a2
commit 92033dff84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -215,7 +215,7 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out
/*
* Allocate file and memory data structures.
*/
if (NULL == (bt = H5FL_MALLOC(H5B_t)))
if (NULL == (bt = H5FL_CALLOC(H5B_t)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node");
memset(&bt->cache_info, 0, sizeof(H5AC_info_t));
bt->level = 0;