summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-06-16 10:43:01 -0400
committerNick Mathewson <nickm@torproject.org>2016-06-16 10:43:01 -0400
commit79370914d1a88adde03dc514bf94fc3e6c3c030c (patch)
tree207e3f7b08986cdff2adc2b8c699cfc89c4305e6 /src/common
parent41cb26c1696b2e91f6ffe28c98ab471b925de9e8 (diff)
downloadtor-79370914d1a88adde03dc514bf94fc3e6c3c030c.tar.gz
tor-79370914d1a88adde03dc514bf94fc3e6c3c030c.zip
tests for size_mul_check__()
it's important, and we should make sure we got it right.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c9
-rw-r--r--src/common/util.h4
2 files changed, 13 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index d005dade53..884d74f71b 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -206,6 +206,15 @@ size_mul_check(const size_t x, const size_t y)
x <= SIZE_MAX / y);
}
+#ifdef TOR_UNIT_TESTS
+/** Exposed for unit tests only */
+int
+size_mul_check__(const size_t x, const size_t y)
+{
+ return size_mul_check(x,y);
+}
+#endif
+
/** Allocate a chunk of <b>nmemb</b>*<b>size</b> bytes of memory, fill
* the memory with zero bytes, and return a pointer to the result.
* Log and terminate the process on error. (Same as
diff --git a/src/common/util.h b/src/common/util.h
index 4c5070e65b..3a056bcd7d 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -535,6 +535,10 @@ STATIC int format_helper_exit_status(unsigned char child_state,
#endif
+#ifdef TOR_UNIT_TESTS
+int size_mul_check__(const size_t x, const size_t y);
+#endif
+
#define ARRAY_LENGTH(x) ((sizeof(x)) / sizeof(x[0]))
#endif