]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
mce-amd-k8: be sure to not go past error_msg buffer
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 14 Aug 2018 16:13:54 +0000 (13:13 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 14 Aug 2018 16:13:54 +0000 (13:13 -0300)
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 <mchehab+samsung@kernel.org>
mce-amd-k8.c

index c8aa44c45c5d1fa12dd8d3ce27078d8304771733..dc772c2e150dd8a5978e9ab8598b8a3b9df0104b 100644 (file)
@@ -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;