mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 07:15:58 +08:00
mDNS: Avoid uninitialized memory
Use calloc() instead of malloc().
This commit is contained in:
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user