summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-03-25 18:05:39 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-03-25 18:05:39 -0400
commit9d82dacf41f935a8dfbb073902c475852e1beeb4 (patch)
tree379a6e8e20c8659a45c14e7200f7960cb0c8fd58
parent17935c22d4f70260182e1b8a2a0be1e686fb79e3 (diff)
downloadmanifesto-9d82dacf41f935a8dfbb073902c475852e1beeb4.tar.gz
manifesto-9d82dacf41f935a8dfbb073902c475852e1beeb4.tar.bz2
manifesto-9d82dacf41f935a8dfbb073902c475852e1beeb4.zip
Fixed potential Heartbleed on startup
If the corpus has been completed by the bot, the bot will quit on its own. However, if the bot is restarted, it will not recognize that it has completed the corpus and will attempt to tweet data from memory. This has been fixed.
-rw-r--r--manifesto.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/manifesto.cpp b/manifesto.cpp index 3c440c3..6fc35f8 100644 --- a/manifesto.cpp +++ b/manifesto.cpp
@@ -35,11 +35,14 @@ int main(int argc, char** argv)
35 std::ifstream corpus(config["corpus"].as<std::string>()); 35 std::ifstream corpus(config["corpus"].as<std::string>());
36 corpus.ignore(loc); 36 corpus.ignore(loc);
37 37
38 char buffer[140]; 38 if (!corpus.eof())
39 while (corpus)
40 { 39 {
41 corpus.read(buffer, 140); 40 char buffer[140];
42 tweets.push_back(std::string(buffer, 140)); 41 while (corpus)
42 {
43 corpus.read(buffer, 140);
44 tweets.push_back(std::string(buffer, 140));
45 }
43 } 46 }
44 } 47 }
45 48
@@ -69,4 +72,6 @@ int main(int argc, char** argv)
69 72
70 std::this_thread::sleep_for(std::chrono::hours(6)); 73 std::this_thread::sleep_for(std::chrono::hours(6));
71 } 74 }
75
76 std::cout << "Corpus complete!" << std::endl;
72} 77}