Skip to content

Why is it not necessary to determine a common year or a leap year here #752

@DeviceTreeBlob

Description

@DeviceTreeBlob

Hi all,

For the BOOLEAN EFIAPI ConvertAsn1TimeToEfiTime (IN ASN1_TIME *Asn1Time, OUT EFI_TIME *EfiTime) interface in Cryptlib/Pk/CryptTs.c, I have some questions.

EfiTime->Month = (Str[Index++] - '0') * 10;
EfiTime->Month += (Str[Index++] - '0');
if ((EfiTime->Month < 1) || (EfiTime->Month > 12)) {
return FALSE;
}

EfiTime->Day = (Str[Index++] - '0') * 10;
EfiTime->Day += (Str[Index++] - '0');
if ((EfiTime->Day < 1) || (EfiTime->Day > 31)) {
return FALSE;
}

Here, the validity of EfiTime->Day is not checked based on EfiTime->Month and EfiTime->Year. For instance, when EfiTime->Month is 2, EfiTime->Day in a common year should not exceed 28, and in a leap year, it should not exceed 29. When EfiTime->Month is 4, EfiTime->Day should not exceed 30.

Why is it only necessary to check whether EfiTime->Day is between 1 and 31 here? Could anyone help explain this? Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions