mDNS: Avoid uninitialized memory

Use calloc() instead of malloc().
This commit is contained in:
Sebastian Huber
2014-11-04 11:56:59 +01:00
parent a736dda8a8
commit d496d66f63
2 changed files with 3 additions and 3 deletions

View File

@@ -834,7 +834,7 @@ mDNSlocal int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, struct
assert(intfMask != NULL);
// Allocate the interface structure itself.
intf = (PosixNetworkInterface*)malloc(sizeof(*intf));
intf = (PosixNetworkInterface*)calloc(1, sizeof(*intf));
if (intf == NULL) { assert(0); err = ENOMEM; }
// And make a copy of the intfName.
@@ -1433,7 +1433,7 @@ mDNSexport void mDNSPlatformMemZero(void *dst, mDNSu32 len)
memset(dst, 0, len);
}
mDNSexport void * mDNSPlatformMemAllocate(mDNSu32 len) { return(malloc(len)); }
mDNSexport void * mDNSPlatformMemAllocate(mDNSu32 len) { return(calloc(1, len)); }
mDNSexport void mDNSPlatformMemFree (void *mem) { free(mem); }
mDNSexport mDNSu32 mDNSPlatformRandomSeed(void)

View File

@@ -245,7 +245,7 @@ struct ifi_info *get_ifi_info(int family, int doaliases)
lastlen = 0;
len = 100 * sizeof(struct ifreq); /* initial buffer size guess */
for ( ; ; ) {
buf = (char*)malloc(len);
buf = (char*)calloc(1, len);
if (buf == NULL) {
goto gotError;
}