]> 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)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Wed, 26 Feb 2020 01:39:17 +0000 (08:39 +0700)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 9accb70e228eed6bdd9f82d64476f0b776cee30b)

src/common/blkdev.cc

index 6f8958eafac314e07f74d29832f7aded5930e20e..7d30c715862ff3ccd46d9ae7cb486a9c094ae0b2 100644 (file)
@@ -725,10 +725,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;