From 0a7e7d09dd91354277e697495bd8fb05626987a9 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Wed, 12 Nov 2025 05:50:23 +0000 Subject: [PATCH] log: use sizeof(*hdr) instead of sizeof(hdr) Using sizeof(hdr) where hdr is a pointer gives the size of the pointer, not the size of the structure it points to. Reported-by: Kir Kolyshkin Signed-off-by: Andrei Vagin --- criu/log.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/criu/log.c b/criu/log.c index fe7077702..bf6f657f2 100644 --- a/criu/log.c +++ b/criu/log.c @@ -190,7 +190,7 @@ void flush_early_log_buffer(int fd) * with reading the log_level. */ struct early_log_hdr *hdr = (void *)early_log_buffer + pos; - pos += sizeof(hdr); + pos += sizeof(*hdr); if (hdr->level <= current_loglevel) { size_t size = 0; while (size < hdr->len) { @@ -323,7 +323,7 @@ static void early_vprint(const char *format, unsigned int loglevel, va_list para int log_size = 0, log_space; struct early_log_hdr *hdr; - if ((early_log_buf_off + sizeof(hdr)) >= EARLY_LOG_BUF_LEN) + if ((early_log_buf_off + sizeof(*hdr)) >= EARLY_LOG_BUF_LEN) return; /* Save loglevel */ @@ -331,7 +331,7 @@ static void early_vprint(const char *format, unsigned int loglevel, va_list para hdr = (void *)early_log_buffer + early_log_buf_off; hdr->level = loglevel; /* Skip the log entry size */ - early_log_buf_off += sizeof(hdr); + early_log_buf_off += sizeof(*hdr); log_space = EARLY_LOG_BUF_LEN - early_log_buf_off; if (loglevel >= LOG_TIMESTAMP) { /*