]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/blkdev: fix smartctl output in error path
authorSage Weil <sage@redhat.com>
Mon, 1 Jul 2019 22:25:32 +0000 (17:25 -0500)
committerSage Weil <sage@redhat.com>
Mon, 1 Jul 2019 22:25:32 +0000 (17:25 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/blkdev.cc

index 4ecd1d8d3f48df219263c4b114b619932e53683a..789e7e087c232fea341c374664467abc3216f154 100644 (file)
@@ -727,10 +727,11 @@ int block_device_get_metrics(const string& devname, int timeout,
   // smartctl
   if (int r = block_device_run_smartctl(devname, timeout, &s);
       r != 0) {
+    string orig = s;
     s = "{\"error\": \"smartctl failed\", \"dev\": \"/dev/";
     s += devname;
     s += "\", \"smartctl_error_code\": " + stringify(r);
-    s += "\", \"smartctl_output\": \"" + s;
+    s += "\", \"smartctl_output\": \"" + escape_quotes(orig);
     s += + "\"}";
   } else if (!json_spirit::read(s, *result)) {
     string orig = s;