if (!CryptGenRandom(provider, sizeof(buf), buf))
return -1;
arc4_addrandom(buf, sizeof(buf));
- memset(buf, 0, sizeof(buf));
+ evutil_memclear_(buf, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
return -1;
arc4_addrandom(buf, sizeof(buf));
- memset(buf, 0, sizeof(buf));
+ evutil_memclear_(buf, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
return -1;
arc4_addrandom(buf, sizeof(buf));
- memset(buf, 0, sizeof(buf));
+ evutil_memclear_(buf, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
arc4_addrandom(entropy, nybbles/2);
bytes += nybbles/2;
}
- memset(entropy, 0, sizeof(entropy));
- memset(buf, 0, sizeof(buf));
+ evutil_memclear_(entropy, sizeof(entropy));
+ evutil_memclear_(buf, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
if (n != sizeof(buf))
return -1;
arc4_addrandom(buf, sizeof(buf));
- memset(buf, 0, sizeof(buf));
+ evutil_memclear_(buf, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
#endif
}
+/**
+ * Volatile pointer to memset: we use this to keep the compiler from
+ * eliminating our call to memset.
+ */
+void * (*volatile evutil_memset_volatile_)(void *, int, size_t) = memset;
+
+void
+evutil_memclear_(void *mem, size_t len)
+{
+ evutil_memset_volatile_(mem, 0, len);
+}
+
int
evutil_sockaddr_is_loopback(const struct sockaddr *addr)
{