summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-07-09 22:49:48 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-07-09 22:49:48 +0100
commit17d7f9e8e6e5e41ef3411728671e414319726727 (patch)
tree0d9e2a09a793e921afd5960347b132e69eb30ec8
parent2b15e7be74ba61fc1f14a92fda98b654ff8daa2c (diff)
Make sure debug lines printed to file end with a trailing newline.
-rw-r--r--TODO2
-rw-r--r--functions.c8
2 files changed, 8 insertions, 2 deletions
diff --git a/TODO b/TODO
index e57cbf0..08e2f32 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
Make some unnecessary configuration options optional (e.g. replaytime if replaymode != "time")
Fuzzing.
-
-If openssl_error_string() doesn't get a string just after SSL_accept() then the debug log entry will fail to contain a trailing new line - maybe make log function ensure last character is new line?
diff --git a/functions.c b/functions.c
index ad92dd3..a67776f 100644
--- a/functions.c
+++ b/functions.c
@@ -119,6 +119,14 @@ void debugprint(int level, char *format, ...) {
if ((bytes = vfprintf(fp, format, args)) < 0) {
debugprint(DEBUG_CRIT, "error: could not write to debug file.\n"); // TODO - This might not be useful if we can't write
}
+
+ // Make sure the finished log line ended with a trailing newline
+ if (format[strlen(format) - 1] != '\n') {
+ if ((bytes = fprintf(fp, "%c", '\n')) < 0) {
+ debugprint(DEBUG_CRIT, "error: could not write trailing newline to debug file.\n"); // TODO - This might not be useful if we can't write
+ }
+ }
+
fclose(fp);
va_end(args);