diff options
author | Tejun Heo <tj@kernel.org> | 2009-08-16 08:01:22 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2009-09-08 21:17:47 -0400 |
commit | 02c24fa87724bb3af969463cd74dc3b3feb24740 (patch) | |
tree | 8ffcdc8e5aa79cc10f0658c11aaebe2d14d4aaf9 /drivers/firmware | |
parent | bd30add88cea831dfb854d564478f09ee66206b5 (diff) |
dmi: fix date handling in dmi_get_year()
Year parsing in dmi_get_year() had the following two bugs.
* "00" is treated as invalid instead of 2000 because zero return from
simple_strtoul() is treated as error.
* "0N" where N >= 8 is treated as invalid of 200N because the leading
0 is considered to specify octal.
Fix the above two bugs by using endptr to detect invalid number and
forcing decimal.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/dmi_scan.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 24c84ae8152..531e621677c 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -577,6 +577,7 @@ int dmi_get_year(int field) | |||
577 | { | 577 | { |
578 | int year; | 578 | int year; |
579 | const char *s = dmi_get_system_info(field); | 579 | const char *s = dmi_get_system_info(field); |
580 | char *e; | ||
580 | 581 | ||
581 | if (!s) | 582 | if (!s) |
582 | return -1; | 583 | return -1; |
@@ -587,8 +588,8 @@ int dmi_get_year(int field) | |||
587 | return 0; | 588 | return 0; |
588 | 589 | ||
589 | s += 1; | 590 | s += 1; |
590 | year = simple_strtoul(s, NULL, 0); | 591 | year = simple_strtoul(s, &e, 10); |
591 | if (year && year < 100) { /* 2-digit year */ | 592 | if (s != e && year < 100) { /* 2-digit year */ |
592 | year += 1900; | 593 | year += 1900; |
593 | if (year < 1996) /* no dates < spec 1.0 */ | 594 | if (year < 1996) /* no dates < spec 1.0 */ |
594 | year += 100; | 595 | year += 100; |