What is a std::string?
aturt13
Some obligatory memes…
Some obligatory memes…
Huh? std::string?
std::string str;
std::getline(std::cin, str); // Read until a newline character is encountered
Nah?
std::string str;
std::getline(std::cin, str); // Read until a newline character is encountered
But what is it, really?
0xc0: 0x0000000000000000 0x0000000000000031 <- chunk size or flags
0xd0: 0x000055555556c6e0 0x0000000000000004 <- string pointer | length
0xe0: 0x0000000074736574 0x0000000000000000 <- the actual short string
Longer strings?
0xc0: 0x0000000000000000 0x0000000000000031 <- chunk size or flags
0xd0: 0x000055555556c700 0x000000000000001a <- string pointer | length
0xe0: 0x000000000000001e 0x0065676e6f6c6d6f <- old string content
0xf0: 0x0000000000000000 0x0000000000000031 <- another chunk metadata
0x00: 0x646e6172656d6f73 0x7265676e6f6c6d6f <- new string content
0x10: 0x6568676e69727473 0x0000000000006568
Longer strings?
0xc0: 0x0000000000000000 0x0000000000000031 <- chunk size or flags
0xd0: 0x000055555556ced0 0x0000000000000400 <- string pointer | size
0xe0: 0x0000000000000780 0x0042424242424242 <- buffer size | old string
How do we read to strings?
But what can we do with strings?
What if the string pointer gets overwritten after free?
How do we get heap vulnerabilities in C++, though?
A short note on std::string_view