Index: PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c =================================================================== --- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c (revision 9330) +++ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c (working copy) @@ -243,6 +243,7 @@ EFI_STATUS Status; RTC_REGISTER_B RegisterB; UINT8 Century; + EFI_TIME TimeCopy; // // Check parameters for null pointer @@ -275,15 +276,15 @@ // // Get the Time/Date/Daylight Savings values. // - Time->Second = RtcRead (RTC_ADDRESS_SECONDS); - Time->Minute = RtcRead (RTC_ADDRESS_MINUTES); - Time->Hour = RtcRead (RTC_ADDRESS_HOURS); - Time->Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH); - Time->Month = RtcRead (RTC_ADDRESS_MONTH); - Time->Year = RtcRead (RTC_ADDRESS_YEAR); + TimeCopy.Second = RtcRead (RTC_ADDRESS_SECONDS); + TimeCopy.Minute = RtcRead (RTC_ADDRESS_MINUTES); + TimeCopy.Hour = RtcRead (RTC_ADDRESS_HOURS); + TimeCopy.Day = RtcRead (RTC_ADDRESS_DAY_OF_THE_MONTH); + TimeCopy.Month = RtcRead (RTC_ADDRESS_MONTH); + TimeCopy.Year = RtcRead (RTC_ADDRESS_YEAR); - Century = RtcRead (RTC_ADDRESS_CENTURY); - + Century = RtcRead (RTC_ADDRESS_CENTURY); + // // Release RTC Lock. // @@ -294,16 +295,18 @@ // // Get the variable that contains the TimeZone and Daylight fields // - Time->TimeZone = Global->SavedTimeZone; - Time->Daylight = Global->Daylight; + TimeCopy.TimeZone = Global->SavedTimeZone; + TimeCopy.Daylight = Global->Daylight; // // Make sure all field values are in correct range // - Status = ConvertRtcTimeToEfiTime (Time, Century, RegisterB); + Status = ConvertRtcTimeToEfiTime (&TimeCopy, Century, RegisterB); + //DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, Status)); if (!EFI_ERROR (Status)) { - Status = RtcTimeFieldsValid (Time); + Status = RtcTimeFieldsValid (&TimeCopy); } + //DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, Status)); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } @@ -323,6 +326,8 @@ Capabilities->SetsToZero = FALSE; } + CopyMem(Time, &TimeCopy, sizeof(*Time)); + return EFI_SUCCESS; } @@ -800,8 +805,9 @@ IN EFI_TIME *Time ) { - if (Time->Year < 1998 || - Time->Year > 2099 || + if ( + //Time->Year < 1998 || + //Time->Year > 2099 || Time->Month < 1 || Time->Month > 12 || (!DayValid (Time)) || @@ -848,12 +854,12 @@ // // The validity of Time->Month field should be checked before // - ASSERT (Time->Month >=1); - ASSERT (Time->Month <=12); - if (Time->Day < 1 || - Time->Day > DayOfMonth[Time->Month - 1] || + ASSERT (Time->Month >= 1 && Time->Month <= 12); + + if ( Time->Day > DayOfMonth[Time->Month - 1] || (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28)) ) { + DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, EFI_INVALID_PARAMETER)); return FALSE; }