diff options
author | Roopesh Chander <roop@roopc.net> | 2018-12-13 17:10:24 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-12-13 17:37:14 +0530 |
commit | 12503ae51db22449309ea2284ae15cf02cadb174 (patch) | |
tree | 911c805f3e2bbf32c806489bc51c580e6dab7c33 /WireGuard/Shared | |
parent | Logging: Use ringlogger for logging from the extension (diff) | |
download | wireguard-apple-12503ae51db22449309ea2284ae15cf02cadb174.tar.xz wireguard-apple-12503ae51db22449309ea2284ae15cf02cadb174.zip |
Logging: ringlogger.c: Trim trailing newlines
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/Shared')
-rw-r--r-- | WireGuard/Shared/Logging/ringlogger.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/WireGuard/Shared/Logging/ringlogger.c b/WireGuard/Shared/Logging/ringlogger.c index ea862de..11de0c3 100644 --- a/WireGuard/Shared/Logging/ringlogger.c +++ b/WireGuard/Shared/Logging/ringlogger.c @@ -29,6 +29,13 @@ void write_msg_to_log(struct log *log, const char *msg) strncpy(line->line, msg, MAX_LOG_LINE_LENGTH - 1); line->line[MAX_LOG_LINE_LENGTH - 1] = '\0'; + // Trim trailing newlines + unsigned long length = strlen(msg); + while ((length > 0) && (msg[length - 1] == '\n' || msg[length - 1] == '\r')) { + line->line[length - 1] = '\0'; + length--; + } + msync(&log->header, sizeof(log->header), MS_ASYNC); msync(line, sizeof(*line), MS_ASYNC); } |