Improve cleanup in fuzzing harnesses

This commit is contained in:
Denis Kasak 2021-07-08 14:23:55 +00:00 committed by Hubert Chathi
parent 254a4a5619
commit 4901435a0e
6 changed files with 29 additions and 16 deletions

View file

@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) {
decode_message(*reader, message_buffer, message_length, 8);
free(message_buffer);
delete reader;
return EXIT_SUCCESS;
}

View file

@ -3,11 +3,10 @@
#include "fuzzing.hh"
int main(int argc, const char *argv[]) {
size_t ignored;
if (argc <= 3) {
const char * message = "Usage: decrypt: <session_key> <session_file>"
" <message_type>\n";
ignored = write(STDERR_FILENO, message, strlen(message));
(void)write(STDERR_FILENO, message, strlen(message));
exit(3);
}
@ -59,7 +58,12 @@ int main(int argc, const char *argv[]) {
)
);
ignored = write(STDOUT_FILENO, plaintext, length);
ignored = write(STDOUT_FILENO, "\n", 1);
return ignored;
(void)write(STDOUT_FILENO, plaintext, length);
(void)write(STDOUT_FILENO, "\n", 1);
free(session_buffer);
free(message_buffer);
free(tmp_buffer);
return EXIT_SUCCESS;
}

View file

@ -3,10 +3,9 @@
#include "fuzzing.hh"
int main(int argc, const char *argv[]) {
size_t ignored;
if (argc <= 2) {
const char * message = "Usage: decrypt <pickle_key> <group_session>\n";
ignored = write(STDERR_FILENO, message, strlen(message));
(void)write(STDERR_FILENO, message, strlen(message));
exit(3);
}
@ -67,7 +66,12 @@ int main(int argc, const char *argv[]) {
)
);
ignored = write(STDOUT_FILENO, plaintext, length);
ignored = write(STDOUT_FILENO, "\n", 1);
return ignored;
(void)write(STDOUT_FILENO, plaintext, length);
(void)write(STDOUT_FILENO, "\n", 1);
free(session_buffer);
free(message_buffer);
free(tmp_buffer);
return EXIT_SUCCESS;
}

View file

@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) {
unpickle(pickle_buffer, pickle_buffer + pickle_length, *account);
free(pickle_buffer);
delete account;
return EXIT_SUCCESS;
}

View file

@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) {
unpickle(pickle_buffer, pickle_buffer + pickle_length, *session);
free(pickle_buffer);
delete session;
return EXIT_SUCCESS;
}

View file

@ -77,13 +77,12 @@ size_t check_error(
) {
if (value == olm_error()) {
const char * olm_message = f(object);
ssize_t ignored;
ignored = write(STDERR_FILENO, message, strlen(message));
ignored = write(STDERR_FILENO, ": ", 2);
ignored = write(STDERR_FILENO, olm_message, strlen(olm_message));
ignored = write(STDERR_FILENO, "\n", 1);
(void)write(STDERR_FILENO, message, strlen(message));
(void)write(STDERR_FILENO, ": ", 2);
(void)write(STDERR_FILENO, olm_message, strlen(olm_message));
(void)write(STDERR_FILENO, "\n", 1);
exit(2);
return ignored;
}
return value;
}