Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Y2038 problem in timespec_from_double. #6

Open
ian-abbott opened this issue Nov 30, 2021 · 0 comments
Open

Possible Y2038 problem in timespec_from_double. #6

ian-abbott opened this issue Nov 30, 2021 · 0 comments

Comments

@ian-abbott
Copy link

timespec_from_double has this initialized variable:

	struct timespec ts = {
		.tv_sec  = s,
		.tv_nsec = (s - (long)(s)) * NSEC_PER_SEC,
	};

On platforms with 32-bit long and the usual Unix time epoch of Jan 1, 1970, this will suffer from the Year 2038 problem even if the platform uses a 64-bit time_t.

The C standard declares the tv_sec member to be of type time_t, so it should be sufficient to replace the conversion (long)(s) with (time_t)(s) (assuming time_t is an integer type because the existing code already assumes that!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant