From ee5c7318d70f61fc735f64ea28603550af54f8df Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 1 Jun 2018 11:31:39 -0600 Subject: [PATCH] Require quotes when searching for blkid keys. In combination with a blkid change, this prevents the parsing logic from getting confused by key names appearing inside values. (The blkid change suppresses any quotes that appear inside values.) Bug: 80436257 Test: manual Change-Id: I9480ef6eb78254b812c671950875d0b8918a27c6 --- Utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Utils.cpp b/Utils.cpp index e19c9df..5de4dbf 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -189,17 +189,17 @@ static status_t readMetadata(const std::string& path, std::string& fsType, for (auto line : output) { // Extract values from blkid output, if defined const char* cline = line.c_str(); - char* start = strstr(cline, "TYPE="); + char* start = strstr(cline, "TYPE=\""); if (start != nullptr && sscanf(start + 5, "\"%127[^\"]\"", value) == 1) { fsType = value; } - start = strstr(cline, "UUID="); + start = strstr(cline, "UUID=\""); if (start != nullptr && sscanf(start + 5, "\"%127[^\"]\"", value) == 1) { fsUuid = value; } - start = strstr(cline, "LABEL="); + start = strstr(cline, "LABEL=\""); if (start != nullptr && sscanf(start + 6, "\"%127[^\"]\"", value) == 1) { fsLabel = value; }