On 07/08/2009 08:46 AM, Matthias Pfaller wrote:Jiri Slaby wrote:Don't guess a year number base. Use 10 instead, since year mayI just noticed, that this is not enough, because this will still fail
be 2-digit starting with 0, so that we would end up in base equal
to 8.
Signed-off-by: Jiri Slaby <jirislaby@xxxxxxxxx>
Reported-by: Matthias Pfaller <leo@xxxxxxxx>
---
drivers/firmware/dmi_scan.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 6071078..8fe0f6e 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -611,7 +611,7 @@ int dmi_get_year(int field)
return 0;
s += 1;
- year = simple_strtoul(s, NULL, 0);
+ year = simple_strtoul(s, NULL, 10);
if (year && year < 100) { /* 2-digit year */
year += 1900;
if (year < 1996) /* no dates < spec 1.0 */
for xxx/xx/00. I suggest the following patch:
Actually the patch below is not correct. Standard says consider xx/xx/yy
as 19yy, not 20yy.
BTW. the patch above is not useful, reporting 1908 and 1909 as a year is
almost the same as 1900.
Do you have such a broken BIOS?
--- drivers/firmware/dmi_scan.c.bak Wed Jul 8 02:42:04 2009
+++ drivers/firmware/dmi_scan.c Wed Jul 8 02:42:17 2009
@@ -360,12 +360,15 @@
return 0;
s += 1;
- year = simple_strtoul(s, NULL, 0);
- if (year && year < 100) { /* 2-digit year */
- year += 1900;
- if (year < 1996) /* no dates < spec 1.0 */
- year += 100;
+ if (s[0] == '0' && s[1] == '0' && s[2] == '\0') {
+ year = 2000;
+ } else {
+ year = simple_strtoul(s, NULL, 10);
+ if (year && year < 100) { /* 2-digit year */
+ year += 1900;
+ if (year < 1996) /* no dates < spec 1.0 */
+ year += 100;
+ }
}
-
return year;
}