From: Kefu Chai Date: Fri, 31 May 2019 14:34:28 +0000 (+0800) Subject: global/global_context: always add '\0' after strncpy() X-Git-Tag: v15.1.0~2547^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28365%2Fhead;p=ceph.git global/global_context: always add '\0' after strncpy() see also f35fa1c58cf24275458cb83097c57bdfd1184cf8 Signed-off-by: Kefu Chai --- diff --git a/src/global/global_context.cc b/src/global/global_context.cc index 1841317fde48..b6d42eaffec5 100644 --- a/src/global/global_context.cc +++ b/src/global/global_context.cc @@ -57,10 +57,12 @@ int note_io_error_event( { g_eio = true; if (devname) { - strncpy(g_eio_devname, devname, sizeof(g_eio_devname)); + strncpy(g_eio_devname, devname, sizeof(g_eio_devname) - 1); + g_eio_devname[sizeof(g_eio_devname) - 1] = '\0'; } if (path) { - strncpy(g_eio_path, path, sizeof(g_eio_path)); + strncpy(g_eio_path, path, sizeof(g_eio_path) - 1); + g_eio_path[sizeof(g_eio_path) - 1] = '\0'; } g_eio_error = error; g_eio_iotype = iotype;