summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-lib.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2006-09-30 23:28:16 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 00:39:25 -0700
commitdb621f174d2c017d960089ea8cbc91c0763f1069 (patch)
tree68a6ab944fdd30b2e6a7a0fb5a06629a4f4a6af9 /drivers/rtc/rtc-lib.c
parent818a8674b0388d90e33a5d1b13946b40dda7032a (diff)
[PATCH] RTC class: error checks
The rtc_is_valid_tm() routine needs to treat some of the fields it checks as unsigned, to prevent wrongly accepting invalid rtc_time structs; this is the same approach used elsewhere in the RTC code for such tests. Conversely, rtc_proc_show() is missing one invalid-day-of-month test that rtc_is_valid_tm() makes: there is no day zero. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/rtc/rtc-lib.c')
-rw-r--r--drivers/rtc/rtc-lib.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index 9812120f3a7..ba795a4db1e 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -94,12 +94,12 @@ EXPORT_SYMBOL(rtc_time_to_tm);
int rtc_valid_tm(struct rtc_time *tm)
{
if (tm->tm_year < 70
- || tm->tm_mon >= 12
+ || ((unsigned)tm->tm_mon) >= 12
|| tm->tm_mday < 1
|| tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + 1900)
- || tm->tm_hour >= 24
- || tm->tm_min >= 60
- || tm->tm_sec >= 60)
+ || ((unsigned)tm->tm_hour) >= 24
+ || ((unsigned)tm->tm_min) >= 60
+ || ((unsigned)tm->tm_sec) >= 60)
return -EINVAL;
return 0;