From: Mauro Carvalho Chehab Date: Tue, 14 Aug 2018 16:13:54 +0000 (-0300) Subject: mce-amd-k8: be sure to not go past error_msg buffer X-Git-Tag: v0.6.2~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=54a74d94ac0c296c24e66efbee916afab1e3045f;p=users%2Fmchehab%2Frasdaemon.git mce-amd-k8: be sure to not go past error_msg buffer As warned by gcc: mce-amd-k8.c: In function ‘decode_k8_generic_errcode’: mce-amd-k8.c:136:30: warning: ‘) ’ directive output may be truncated writing 2 bytes into a region of size between 0 and 4095 [-Wformat-truncation=] mce_snprintf(e->error_msg, "(%s) ", tmp_buf); ^~~~~~~ ras-mce-handler.h:104:29: note: in definition of macro ‘mce_snprintf’ snprintf(buf + __n, __len, fmt, ##arg); \ ^~~ ras-mce-handler.h:104:2: note: ‘snprintf’ output between 4 and 4099 bytes into a destination of size 4096 snprintf(buf + __n, __len, fmt, ##arg); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mce-amd-k8.c:136:3: note: in expansion of macro ‘mce_snprintf’ mce_snprintf(e->error_msg, "(%s) ", tmp_buf); ^~~~~~~~~~~~ Signed-off-by: Mauro Carvalho Chehab --- diff --git a/mce-amd-k8.c b/mce-amd-k8.c index c8aa44c..dc772c2 100644 --- a/mce-amd-k8.c +++ b/mce-amd-k8.c @@ -125,7 +125,7 @@ static const char *highbits[32] = { static void decode_k8_generic_errcode(struct mce_event *e) { - char tmp_buf[4096]; + char tmp_buf[4092]; unsigned short errcode = e->status & 0xffff; int n;