summaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-02-27 16:25:25 -0500
committerNick Mathewson <nickm@torproject.org>2017-02-27 16:25:25 -0500
commitc0aa7ac5acd7b6f1d261a8a6eb5db2d3571e1f2f (patch)
tree0e2d5196e236390f7f4fb85272ea25a22d73afeb /src/or/buffers.c
parent4808540d5c8e132c6ea4db13e25faff6446dc674 (diff)
parentb923c4dc9f011ab8f62e03211407d042dbe9f92a (diff)
downloadtor-c0aa7ac5acd7b6f1d261a8a6eb5db2d3571e1f2f.tar.gz
tor-c0aa7ac5acd7b6f1d261a8a6eb5db2d3571e1f2f.zip
Merge branch 'disable_memory_sentinels_squashed'
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 603da1bb6e..155b1935ed 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -83,7 +83,11 @@ static int parse_socks_client(const uint8_t *data, size_t datalen,
#define CHUNK_HEADER_LEN STRUCT_OFFSET(chunk_t, mem[0])
/* We leave this many NUL bytes at the end of the buffer. */
+#ifdef DISABLE_MEMORY_SENTINELS
+#define SENTINEL_LEN 0
+#else
#define SENTINEL_LEN 4
+#endif
/* Header size plus NUL bytes at the end */
#define CHUNK_OVERHEAD (CHUNK_HEADER_LEN + SENTINEL_LEN)
@@ -97,18 +101,22 @@ static int parse_socks_client(const uint8_t *data, size_t datalen,
#define DEBUG_SENTINEL
-#ifdef DEBUG_SENTINEL
+#if defined(DEBUG_SENTINEL) && !defined(DISABLE_MEMORY_SENTINELS)
#define DBG_S(s) s
#else
#define DBG_S(s) (void)0
#endif
+#ifdef DISABLE_MEMORY_SENTINELS
+#define CHUNK_SET_SENTINEL(chunk, alloclen) STMT_NIL
+#else
#define CHUNK_SET_SENTINEL(chunk, alloclen) do { \
uint8_t *a = (uint8_t*) &(chunk)->mem[(chunk)->memlen]; \
DBG_S(uint8_t *b = &((uint8_t*)(chunk))[(alloclen)-SENTINEL_LEN]); \
DBG_S(tor_assert(a == b)); \
memset(a,0,SENTINEL_LEN); \
} while (0)
+#endif
/** Return the next character in <b>chunk</b> onto which data can be appended.
* If the chunk is full, this might be off the end of chunk->mem. */