Error when we fail to parse a time
Before, we would get whatever date was on the stack space, which ends
pretty poorly. We can at least explode.
Change-Id: I750c217396934d4283b09037af656f5d2e182d38
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/time/time.cc b/aos/time/time.cc
index 882f925..a956f94 100644
--- a/aos/time/time.cc
+++ b/aos/time/time.cc
@@ -132,6 +132,9 @@
struct tm tm;
std::istringstream ss(std::string(now.substr(0, now.size() - 10)));
ss >> std::get_time(&tm, "%Y-%m-%d_%H-%M-%S");
+ if (ss.fail()) {
+ return std::nullopt;
+ }
tm.tm_isdst = -1;
time_t seconds = mktime(&tm);