Skip to content

Y2038: overflow in strtoday with 32-bit long and 64-bit time_t #704

@dtaylor84

Description

@dtaylor84

I think there's a missing pair of parentheses in strtoday():

https://github.com/shadow-maint/shadow/blob/master/libmisc/strtoday.c#L76

return (long) (t + DAY / 2) / DAY;

should be

return (long) ((t + DAY / 2) / DAY);

to avoid the intermediate calculations overflowing with a 32-bit long.

(Noted here https://rachelbythebay.com/w/2023/01/26/shadow/)

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