aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-03-06 12:08:25 -0500
committerNick Mathewson <nickm@torproject.org>2019-04-04 12:56:52 -0400
commit027c536598f336014d7ef406610207ec4559d490 (patch)
treeb683bcd7728c2e6b1332c1f6dc690f5829f20e7f /src/lib
parent785c3f84de958e90c45e82d6126a8c66958be4e1 (diff)
downloadtor-027c536598f336014d7ef406610207ec4559d490.tar.gz
tor-027c536598f336014d7ef406610207ec4559d490.zip
rename inherit values to avoid conflict with system defines
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/crypt_ops/crypto_rand_fast.c12
-rw-r--r--src/lib/malloc/map_anon.c12
-rw-r--r--src/lib/malloc/map_anon.h6
3 files changed, 15 insertions, 15 deletions
diff --git a/src/lib/crypt_ops/crypto_rand_fast.c b/src/lib/crypt_ops/crypto_rand_fast.c
index 384c172c32..01817c618f 100644
--- a/src/lib/crypt_ops/crypto_rand_fast.c
+++ b/src/lib/crypt_ops/crypto_rand_fast.c
@@ -152,7 +152,7 @@ crypto_fast_rng_new(void)
crypto_fast_rng_t *
crypto_fast_rng_new_from_seed(const uint8_t *seed)
{
- unsigned inherit = INHERIT_KEEP;
+ unsigned inherit = INHERIT_RES_KEEP;
/* We try to allocate this object as securely as we can, to avoid
* having it get dumped, swapped, or shared after fork.
*/
@@ -164,7 +164,7 @@ crypto_fast_rng_new_from_seed(const uint8_t *seed)
result->bytes_left = 0;
result->n_till_reseed = RESEED_AFTER;
#ifdef CHECK_PID
- if (inherit == INHERIT_KEEP) {
+ if (inherit == INHERIT_RES_KEEP) {
/* This value will neither be dropped nor zeroed after fork, so we need to
* check our pid to make sure we are not sharing it across a fork. This
* can be expensive if the pid value isn't cached, sadly.
@@ -176,7 +176,7 @@ crypto_fast_rng_new_from_seed(const uint8_t *seed)
#else
/* We decided above that noinherit would always do _something_. Assert here
* that we were correct. */
- tor_assert(inherit != INHERIT_KEEP);
+ tor_assert(inherit != INHERIT_RES_KEEP);
#endif
return result;
}
@@ -253,12 +253,12 @@ crypto_fast_rng_getbytes_impl(crypto_fast_rng_t *rng, uint8_t *out,
if (rng->owner) {
/* Note that we only need to do this check when we have owner set: that
* is, when our attempt to block inheriting failed, and the result was
- * INHERIT_KEEP.
+ * INHERIT_RES_KEEP.
*
- * If the result was INHERIT_DROP, then any attempt to access the rng
+ * If the result was INHERIT_RES_DROP, then any attempt to access the rng
* memory after forking will crash.
*
- * If the result was INHERIT_ZERO, then forking will set the bytes_left
+ * If the result was INHERIT_RES_ZERO, then forking will set the bytes_left
* and n_till_reseed fields to zero. This function will call
* crypto_fast_rng_refill(), which will in turn reseed the PRNG.
*
diff --git a/src/lib/malloc/map_anon.c b/src/lib/malloc/map_anon.c
index bb0a3d5741..3e1c22648d 100644
--- a/src/lib/malloc/map_anon.c
+++ b/src/lib/malloc/map_anon.c
@@ -123,14 +123,14 @@ noinherit_mem(void *mem, size_t sz, unsigned *inherit_result_out)
#ifdef FLAG_ZERO
int r = MINHERIT(mem, sz, FLAG_ZERO);
if (r == 0) {
- *inherit_result_out = INHERIT_ZERO;
+ *inherit_result_out = INHERIT_RES_ZERO;
return 0;
}
#endif
#ifdef FLAG_NOINHERIT
int r2 = MINHERIT(mem, sz, FLAG_NOINHERIT);
if (r2 == 0) {
- *inherit_result_out = INHERIT_DROP;
+ *inherit_result_out = INHERIT_RES_DROP;
}
return r2;
#else
@@ -154,9 +154,9 @@ noinherit_mem(void *mem, size_t sz, unsigned *inherit_result_out)
* Memory returned from this function must be released with
* tor_munmap_anonymous().
*
- * If <b>inherit_result_out</b> is non-NULL, set it to one of INHERIT_KEEP,
- * INHERIT_DROP, and INHERIT_ZERO, depending on the properties of the returned
- * memory.
+ * If <b>inherit_result_out</b> is non-NULL, set it to one of
+ * INHERIT_RES_KEEP, INHERIT_RES_DROP, or INHERIT_RES_ZERO, depending on the
+ * properties of the returned memory.
*
* [Note: OS people use the word "anonymous" here to mean that the memory
* isn't associated with any file. This has *nothing* to do with the kind of
@@ -170,7 +170,7 @@ tor_mmap_anonymous(size_t sz, unsigned flags, unsigned *inherit_result_out)
if (inherit_result_out == NULL) {
inherit_result_out = &itmp;
}
- *inherit_result_out = INHERIT_KEEP;
+ *inherit_result_out = INHERIT_RES_KEEP;
#if defined(_WIN32)
HANDLE mapping = CreateFileMapping(INVALID_HANDLE_VALUE,
diff --git a/src/lib/malloc/map_anon.h b/src/lib/malloc/map_anon.h
index 89fb9da0f0..f101654eb8 100644
--- a/src/lib/malloc/map_anon.h
+++ b/src/lib/malloc/map_anon.h
@@ -33,13 +33,13 @@
/** Possible value for inherit_result_out: the memory will be kept
* by any child process. */
-#define INHERIT_KEEP 0
+#define INHERIT_RES_KEEP 0
/** Possible value for inherit_result_out: the memory will be dropped in
* the child process. Attempting to access it will likely cause a segfault. */
-#define INHERIT_DROP 1
+#define INHERIT_RES_DROP 1
/** Possible value for inherit_result_out: the memory will be cleared in
* the child process. */
-#define INHERIT_ZERO 2
+#define INHERIT_RES_ZERO 2
/* Here we define the NOINHERIT_CAN_FAIL macro if and only if
* it's possible that ANONMAP_NOINHERIT might yield inheritable memory.