]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
global/global_context: always add '\0' after strncpy() 28365/head
authorKefu Chai <kchai@redhat.com>
Fri, 31 May 2019 14:34:28 +0000 (22:34 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 3 Jun 2019 13:38:32 +0000 (21:38 +0800)
see also f35fa1c58cf24275458cb83097c57bdfd1184cf8

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/global/global_context.cc

index 1841317fde480548d06643b089113d0b6204f832..b6d42eaffec53f214c8f1e73b8c58005e3b52040 100644 (file)
@@ -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;