diff options
author | Oskar <[email protected]> | 2024-08-14 19:58:58 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-08-14 19:58:58 +0200 |
commit | 19f1a70edbf2b08536c114e12f7b3c1e77469730 (patch) | |
tree | 1cb1162c8e205cdb2bcddfbcb1d6a09f2d2ff915 /3p37.cpp | |
parent | c5587e2392d55b3e0dc322c0545ead4a314132c0 (diff) |
Forgot how painful input buffers are
Diffstat (limited to '3p37.cpp')
-rw-r--r-- | 3p37.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/3p37.cpp b/3p37.cpp new file mode 100644 index 0000000..968ce86 --- /dev/null +++ b/3p37.cpp @@ -0,0 +1,26 @@ +#include <iostream> +#include <vector> +#include "sales_data.hpp" +#include "sales_item.hpp" + +/* + * + * 3.37 + * + * + */ + +int main () { + + const char ca[] = {'H', 'e', 'l', 'l', 'o'/*, '\0'*/}; + const char *cp = ca; + while(*cp) { + std::cout << *cp << std::endl; + ++cp; + } + /* + * This causes a buffer overflow because there is no null character at the end of the string + * If we put a null-character at the end of the string we don't get an overflow. + */ + return 0; +} |