Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Slides: Chandler Carruth "Spectre: Secrets, Side-Channels, Sandboxes, and Security" #11

Open
TheMatt2 opened this issue Apr 28, 2021 · 1 comment

Comments

@TheMatt2
Copy link

CppCon 2018: Chandler Carruth "Spectre: Secrets, Side-Channels, Sandboxes, and Security"
https://youtu.be/_f7O3IfIR2k

@TheMatt2
Copy link
Author

Here is one of the files used in the presentation "leaks.cpp"
Rewritten from the video: https://youtu.be/_f7O3IfIR2k?t=420

#include <iostream>
#include <string_view>

constexpr std::string_view text_table[] = {"Hello World!", "Hello CppCon!",
                                           "It's a s3kr3t!!!"};

int main(int argc, char** argv) {
  int text_index = 0;
  if (argc > 1)
    text_index = std::stoi(argv[1]);
  std::cerr << "Text buffer index: " << text_index << "\n";
  if (text_index > 1) {
    std::cerr << "ERROR: Only first two buffers are public!\n";
    exit(1);
  }
  std::string_view text = text_table[text_index];

  int length = text.size();
  if (argc > 2)
    length = std::stoi(argv[2]);
  std::cerr << "Length: " << length << "\n";
  std::cout << text.size() - length << "\n";
  if (text.size() - length < 0) {
    std::cerr << "ERROR: Buffer is only" << text.size() << " characters!\n";
    exit(1);
  }

  std::string_view to_print(text.begin(), length);
  std::cout << to_print << "\n";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant