From 6efb877973fd66ad905d423bebe062bf7dd7c6ba Mon Sep 17 00:00:00 2001 From: Ting-Yuan Huang Date: Tue, 7 Feb 2017 16:40:35 -0800 Subject: [PATCH] liblog: fix an undefined-behavor in __write_to_log_daemon() The behavior of passing NULL to c-string functions is undefined. Test: passed clang-tidy checks Bug: none Change-Id: Ie7bcc43cd19bc4a1c314381af3929eae0a6154b9 --- liblog/logger_write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblog/logger_write.c b/liblog/logger_write.c index 43241254f..2599a5394 100644 --- a/liblog/logger_write.c +++ b/liblog/logger_write.c @@ -343,7 +343,7 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr) } } /* tag must be nul terminated */ - if (strnlen(tag, len) >= len) { + if (tag && strnlen(tag, len) >= len) { tag = NULL; }