From 9d82dacf41f935a8dfbb073902c475852e1beeb4 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 25 Mar 2018 18:05:39 -0400 Subject: 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. --- manifesto.cpp | 13 +++++++++---- 1 file 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) std::ifstream corpus(config["corpus"].as()); corpus.ignore(loc); - char buffer[140]; - while (corpus) + if (!corpus.eof()) { - corpus.read(buffer, 140); - tweets.push_back(std::string(buffer, 140)); + char buffer[140]; + while (corpus) + { + corpus.read(buffer, 140); + tweets.push_back(std::string(buffer, 140)); + } } } @@ -69,4 +72,6 @@ int main(int argc, char** argv) std::this_thread::sleep_for(std::chrono::hours(6)); } + + std::cout << "Corpus complete!" << std::endl; } -- cgit 1.4.1