Commit 4901435a authored by Denis Kasak's avatar Denis Kasak Committed by Hubert Chathi
Browse files

Improve cleanup in fuzzing harnesses

parent 254a4a56
Pipeline #7415 passed with stages
in 2 minutes and 47 seconds
...@@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) { ...@@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) {
decode_message(*reader, message_buffer, message_length, 8); decode_message(*reader, message_buffer, message_length, 8);
free(message_buffer); free(message_buffer);
delete reader; delete reader;
return EXIT_SUCCESS;
} }
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
#include "fuzzing.hh" #include "fuzzing.hh"
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
size_t ignored;
if (argc <= 3) { if (argc <= 3) {
const char * message = "Usage: decrypt: <session_key> <session_file>" const char * message = "Usage: decrypt: <session_key> <session_file>"
" <message_type>\n"; " <message_type>\n";
ignored = write(STDERR_FILENO, message, strlen(message)); (void)write(STDERR_FILENO, message, strlen(message));
exit(3); exit(3);
} }
...@@ -59,7 +58,12 @@ int main(int argc, const char *argv[]) { ...@@ -59,7 +58,12 @@ int main(int argc, const char *argv[]) {
) )
); );
ignored = write(STDOUT_FILENO, plaintext, length); (void)write(STDOUT_FILENO, plaintext, length);
ignored = write(STDOUT_FILENO, "\n", 1); (void)write(STDOUT_FILENO, "\n", 1);
return ignored;
free(session_buffer);
free(message_buffer);
free(tmp_buffer);
return EXIT_SUCCESS;
} }
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
#include "fuzzing.hh" #include "fuzzing.hh"
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
size_t ignored;
if (argc <= 2) { if (argc <= 2) {
const char * message = "Usage: decrypt <pickle_key> <group_session>\n"; 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); exit(3);
} }
...@@ -67,7 +66,12 @@ int main(int argc, const char *argv[]) { ...@@ -67,7 +66,12 @@ int main(int argc, const char *argv[]) {
) )
); );
ignored = write(STDOUT_FILENO, plaintext, length); (void)write(STDOUT_FILENO, plaintext, length);
ignored = write(STDOUT_FILENO, "\n", 1); (void)write(STDOUT_FILENO, "\n", 1);
return ignored;
free(session_buffer);
free(message_buffer);
free(tmp_buffer);
return EXIT_SUCCESS;
} }
...@@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) { ...@@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) {
unpickle(pickle_buffer, pickle_buffer + pickle_length, *account); unpickle(pickle_buffer, pickle_buffer + pickle_length, *account);
free(pickle_buffer); free(pickle_buffer);
delete account; delete account;
return EXIT_SUCCESS;
} }
...@@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) { ...@@ -11,4 +11,6 @@ int main(int argc, const char *argv[]) {
unpickle(pickle_buffer, pickle_buffer + pickle_length, *session); unpickle(pickle_buffer, pickle_buffer + pickle_length, *session);
free(pickle_buffer); free(pickle_buffer);
delete session; delete session;
return EXIT_SUCCESS;
} }
...@@ -77,13 +77,12 @@ size_t check_error( ...@@ -77,13 +77,12 @@ size_t check_error(
) { ) {
if (value == olm_error()) { if (value == olm_error()) {
const char * olm_message = f(object); const char * olm_message = f(object);
ssize_t ignored; (void)write(STDERR_FILENO, message, strlen(message));
ignored = write(STDERR_FILENO, message, strlen(message)); (void)write(STDERR_FILENO, ": ", 2);
ignored = write(STDERR_FILENO, ": ", 2); (void)write(STDERR_FILENO, olm_message, strlen(olm_message));
ignored = write(STDERR_FILENO, olm_message, strlen(olm_message)); (void)write(STDERR_FILENO, "\n", 1);
ignored = write(STDERR_FILENO, "\n", 1);
exit(2); exit(2);
return ignored;
} }
return value; return value;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment