Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/patches-2.0'
Browse files Browse the repository at this point in the history
Conflicts:
	util-internal.h
  • Loading branch information
nmathewson committed Aug 19, 2013
2 parents c149a1a + c83efb8 commit 3807a30
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arc4random.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ arc4_seed_win32(void)
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;
}
Expand Down Expand Up @@ -200,7 +200,7 @@ arc4_seed_sysctl_linux(void)
return -1;

arc4_addrandom(buf, sizeof(buf));
memset(buf, 0, sizeof(buf));
evutil_memclear_(buf, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ arc4_seed_sysctl_bsd(void)
return -1;

arc4_addrandom(buf, sizeof(buf));
memset(buf, 0, sizeof(buf));
evutil_memclear_(buf, sizeof(buf));
arc4_seeded_ok = 1;
return 0;
}
Expand Down Expand Up @@ -285,8 +285,8 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
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;
}
Expand All @@ -310,7 +310,7 @@ static int arc4_seed_urandom_helper_(const char *fname)
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;
}
Expand Down
12 changes: 12 additions & 0 deletions evutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,18 @@ evutil_weakrand_range_(struct evutil_weakrand_state *state, ev_int32_t top)
return result;
}

/**
* 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)
{
Expand Down
1 change: 1 addition & 0 deletions util-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ evutil_socket_t evutil_eventfd_(unsigned initval, int flags);
#define EVUTIL_EFD_CLOEXEC 0x8000
#endif

void evutil_memclear_(void *mem, size_t len);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 3807a30

Please sign in to comment.