CppCon2018 icon indicating copy to clipboard operation
CppCon2018 copied to clipboard

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

Open TheMatt2 opened this issue 3 years ago • 1 comments

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

TheMatt2 avatar Apr 28 '21 19:04 TheMatt2

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";
}

TheMatt2 avatar Apr 28 '21 20:04 TheMatt2