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

Y2038 problem with date-and-time #3251

Closed
awesomenode opened this issue Feb 23, 2024 · 3 comments
Closed

Y2038 problem with date-and-time #3251

awesomenode opened this issue Feb 23, 2024 · 3 comments
Labels
is:bug Bug description.

Comments

@awesomenode
Copy link

Hi,

On 32-bit platforms the date-and-time type from ietf-yang-types cannot handle dates properly after year 2038.
For example when I try to set clock through "/ietf-system:set-current-datetime" RPC to year 2040,
the subscribed rpc callback receives year 1970 in the input values.

I attached an example application to reproduce it:
reprod.zip

$ ./reprod  
Setting date-time to 2040-02-23T15:14:35Z 


========== RPC "/ietf-system:set-current-datetime" RECEIVED: ======================= 

/ietf-system:set-current-datetime/current-datetime = 1970-01-01T00:59:59+01:00

libyang version: 2.1.159
sysrepo version: 2.2.155

Thank you in advance!

@michalvasko
Copy link
Collaborator

So I have tested it and reproduced, the cause is timgm() returning -1 (without setting errno for some reason). And based on what I read about this, it seems it is a "feature" of 32b systems so I am not sure what you expect from libyang to make it work.

@michalvasko michalvasko added the is:bug Bug description. label Feb 26, 2024
@jktjkt
Copy link
Contributor

jktjkt commented Feb 26, 2024

In case you can recompile everything (and I mean it, everything, since this is obviously a huge ABI change), and you're already on kernel 5.1+ and glibc 2.34+, then you can set -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 and you're good to go. Beware, though, that you might face some nasty surprises if you have, say, a time_t in some binary on-disk file. If you're using a system such as Buildroot, there's a config option for this already, BR2_TIME_BITS_64.

TL;DR: this fix IMHO belongs to the "system library", not into libyang.

@awesomenode
Copy link
Author

Thank you for the answers!

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

No branches or pull requests

3 participants