Skip to content

Commit

Permalink
Merge pull request #20 from harlowja/affected-bool-exit-status-code
Browse files Browse the repository at this point in the history
Alter return code based on whether affected or not
  • Loading branch information
raphaelsc authored Jan 17, 2018
2 parents a6e3187 + 6c7c952 commit b6f8076
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion meltdown_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ static inline bool has_TSX() {
}

int main(int argc, char** argv) {
bool affected = false;
g_tsx_supported = has_TSX();

if (!g_tsx_supported) {
Expand Down Expand Up @@ -310,6 +311,7 @@ int main(int argc, char** argv) {
if (ret) {
std::cout << "\nSystem affected! Please consider upgrading your kernel to one that is patched with KPTI/KAISER\n";
std::cout << "Check https://security.googleblog.com/2018/01/todays-cpu-vulnerability-what-you-need.html for more details\n";
affected = true;
goto out;
} else {
std::cout << "so far so good (i.e. meltdown safe) ...\n";
Expand All @@ -318,5 +320,11 @@ int main(int argc, char** argv) {
std::cout << "\nSystem not affected (take it with a grain of salt though as false negative may be reported for specific environments; " \
"Please consider running it once again).\n";
out:
return munmap(static_cast<void*>(mem), mem_size());
if(munmap(static_cast<void*>(mem), mem_size()) != 0) {
return -1;
}
if(affected) {
return 1;
}
return 0;
}

0 comments on commit b6f8076

Please sign in to comment.