Commit 09d0298d authored by David Trainor's avatar David Trainor Committed by Commit Bot

Fix a line trim to use the correct offset

We were previously trimming the string with the wrong prefix, which
meant that querying the Cpu brand from /proc/cpuinfo could be wrong if
the string matched "Processor\t: ".  We would use "model name\t: "
length to trim instead of the correct "Processor\t: " length.

BUG=788934

Change-Id: I1cc99e6c64ca89b25f53c51624db40cdafe24a6b
Reviewed-on: https://chromium-review.googlesource.com/791998Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: David Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519802}
parent 4f655475
...@@ -114,10 +114,10 @@ std::string* CpuInfoBrand() { ...@@ -114,10 +114,10 @@ std::string* CpuInfoBrand() {
std::istringstream iss(contents); std::istringstream iss(contents);
std::string line; std::string line;
while (std::getline(iss, line)) { while (std::getline(iss, line)) {
if ((line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0 || if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0)
line.compare(0, strlen(kProcessorPrefix), kProcessorPrefix) == 0)) {
return new std::string(line.substr(strlen(kModelNamePrefix))); return new std::string(line.substr(strlen(kModelNamePrefix)));
} if (line.compare(0, strlen(kProcessorPrefix), kProcessorPrefix) == 0)
return new std::string(line.substr(strlen(kProcessorPrefix)));
} }
return new std::string(); return new std::string();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment