summaryrefslogtreecommitdiff
path: root/firmware/common/timefuncs.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-07-20 00:04:36 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-07-20 23:25:31 +0000
commitb91ad60d6390f20ac7b86e5ae71398cf341d944b (patch)
tree73c9f4e9f0c6fea8484db0da4888bf2a0449cb41 /firmware/common/timefuncs.c
parent966e210e6d699ba69c0f72a2661b0f6204293247 (diff)
downloadrockbox-b91ad60d6390f20ac7b86e5ae71398cf341d944b.tar.gz
rockbox-b91ad60d6390f20ac7b86e5ae71398cf341d944b.zip
timefuncs.c valid_time() should return false if tm == NULL and not try to deref
luckily no one has yet.. Change-Id: I4117db84b013fa826958aea635daa0a24ee534b6
Diffstat (limited to 'firmware/common/timefuncs.c')
-rw-r--r--firmware/common/timefuncs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index 66854dea13..1405a8d926 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -86,13 +86,13 @@ static inline int rtc_read_datetime(struct tm *tm)
86#if CONFIG_RTC 86#if CONFIG_RTC
87bool valid_time(const struct tm *tm) 87bool valid_time(const struct tm *tm)
88{ 88{
89 if (tm->tm_hour < 0 || tm->tm_hour > 23 || 89 if (!tm || (tm->tm_hour < 0 || tm->tm_hour > 23 ||
90 tm->tm_sec < 0 || tm->tm_sec > 59 || 90 tm->tm_sec < 0 || tm->tm_sec > 59 ||
91 tm->tm_min < 0 || tm->tm_min > 59 || 91 tm->tm_min < 0 || tm->tm_min > 59 ||
92 tm->tm_year < 100 || tm->tm_year > 199 || 92 tm->tm_year < 100 || tm->tm_year > 199 ||
93 tm->tm_mon < 0 || tm->tm_mon > 11 || 93 tm->tm_mon < 0 || tm->tm_mon > 11 ||
94 tm->tm_wday < 0 || tm->tm_wday > 6 || 94 tm->tm_wday < 0 || tm->tm_wday > 6 ||
95 tm->tm_mday < 1 || tm->tm_mday > 31) 95 tm->tm_mday < 1 || tm->tm_mday > 31))
96 return false; 96 return false;
97 else 97 else
98 return true; 98 return true;