As far as I can tell, the afs_osi_Alloc contract does not
guarantee zeroed memory. On FreeBSD, with a debug kernel, it
definitely does not currently provide zeroed memory, returning
instead memory initialized with 0xdeadc0de.
Properly speaking, the role of calloc() is to both check for overflow
from the multiplication and to produce zeroed memory. However, since
we do not have a reasonable way to report failure, do not bother
checking for overflow at this time.
Change-Id: I187c2057d473fba869692c1dfa11735502b260c1
Reviewed-on: http://gerrit.openafs.org/11322
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
_afscrypto_calloc(int num, size_t len)
{
void *ptr;
+ size_t total;
- ptr = afs_osi_Alloc(num * len);
+ total = num * len;
+ ptr = afs_osi_Alloc(total);
+ /* In practice, callers assume the afs_osi_Alloc() will not fail. */
+ if (ptr != NULL)
+ memset(ptr, 0, total);
return ptr;
}