From: David Brownell <david-b@pacbell.net>
To: Alessandro Zummo <alessandro.zummo@towertech.it>
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: [patch 2.6.18-rc3] RTC class, error checks
Date: Fri, 4 Aug 2006 17:41:37 -0700 [thread overview]
Message-ID: <200608041741.37482.david-b@pacbell.net> (raw)
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.
Similarly, 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>
Index: osk/drivers/rtc/rtc-lib.c
===================================================================
--- osk.orig/drivers/rtc/rtc-lib.c 2006-05-09 09:42:01.000000000 -0700
+++ osk/drivers/rtc/rtc-lib.c 2006-08-01 22:12:43.000000000 -0700
@@ -75,12 +75,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;
Index: osk/drivers/rtc/rtc-proc.c
===================================================================
--- osk.orig/drivers/rtc/rtc-proc.c 2006-05-09 09:42:01.000000000 -0700
+++ osk/drivers/rtc/rtc-proc.c 2006-08-01 22:15:19.000000000 -0700
@@ -61,7 +61,7 @@ static int rtc_proc_show(struct seq_file
seq_printf(seq, "%02d-", alrm.time.tm_mon + 1);
else
seq_printf(seq, "**-");
- if ((unsigned int)alrm.time.tm_mday <= 31)
+ if (alrm.time.tm_mday && (unsigned int)alrm.time.tm_mday <= 31)
seq_printf(seq, "%02d\n", alrm.time.tm_mday);
else
seq_printf(seq, "**\n");
reply other threads:[~2006-08-05 1:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200608041741.37482.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=alessandro.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox