CppCon2018
CppCon2018 copied to clipboard
Missing Slides: Chandler Carruth "Spectre: Secrets, Side-Channels, Sandboxes, and Security"
CppCon 2018: Chandler Carruth "Spectre: Secrets, Side-Channels, Sandboxes, and Security" https://youtu.be/_f7O3IfIR2k
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";
}