aboutsummaryrefslogtreecommitdiff
path: root/fuzzers/include/fuzzing.hh
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-05-26 13:25:34 +0100
committerMark Haines <mjark@negativecurvature.net>2016-05-26 13:25:34 +0100
commitbfeb554e8699c5cb90cab14dc74e15c30f963d74 (patch)
tree64dfe3776f06874fa591a28b5ff7456c8824b1c0 /fuzzers/include/fuzzing.hh
parentee8172d882e853e737ac7e8b00fb760f21e80bfe (diff)
Add a fuzzer for olm_group_decrypt
Diffstat (limited to 'fuzzers/include/fuzzing.hh')
-rw-r--r--fuzzers/include/fuzzing.hh16
1 files changed, 13 insertions, 3 deletions
diff --git a/fuzzers/include/fuzzing.hh b/fuzzers/include/fuzzing.hh
index e4f5eb9..b27c396 100644
--- a/fuzzers/include/fuzzing.hh
+++ b/fuzzers/include/fuzzing.hh
@@ -53,13 +53,15 @@ T check_errno(
return value;
}
-size_t check_session(
- OlmSession * session,
+template<typename T, typename F>
+size_t check_error(
+ F f,
+ T * object,
const char * message,
size_t value
) {
if (value == olm_error()) {
- const char * olm_message = olm_session_last_error(session);
+ const char * olm_message = f(object);
ssize_t ignored;
ignored = write(STDERR_FILENO, message, strlen(message));
ignored = write(STDERR_FILENO, ": ", 2);
@@ -70,3 +72,11 @@ size_t check_session(
}
return value;
}
+
+size_t check_session(
+ OlmSession * session,
+ const char * message,
+ size_t value
+) {
+ return check_error(olm_session_last_error, session, message, value);
+}