From: Michal Bloch Date: Wed, 18 Nov 2020 10:58:41 +0000 (+0100) Subject: Add an assert() to a scary-looking buffer indexing X-Git-Tag: accepted/tizen/unified/20210301.130201~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eba70888fdc1e685395b6e882784792b628657c3;p=platform%2Fcore%2Fsystem%2Fdlog.git Add an assert() to a scary-looking buffer indexing Static analysis had some worries about a buffer overrun here. Change-Id: I0698ff87c9763c4752f28acd4ad2e4e0953664d4 Signed-off-by: Michal Bloch --- diff --git a/src/shared/queued_entry.c b/src/shared/queued_entry.c index 8c7abe7..a8c3da7 100644 --- a/src/shared/queued_entry.c +++ b/src/shared/queued_entry.c @@ -154,6 +154,7 @@ void fixup_pipe_msg(struct dlogutil_entry_with_msg *dewm, int payload_size) available_space: sizeof WARN_MSG - 1; payload_size += added_size; + assert(payload_size <= sizeof dewm->msg); dewm->header.len += added_size; dewm->msg[payload_size - 1] = '\0'; }