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

IceUtil::Time::toDateTime() crashes when used on dates 17+ years in the future #1283

Closed
FabioOsorioMoreira opened this issue May 27, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@FabioOsorioMoreira
Copy link

Version(please complete the following information):

  • Ice Version: 3.7.2 and 3.7.5
  • OS: Only tested on Windows
  • Language: C++

Describe the bug
If you try to use toDateTime to get a readable string on a date that is several years on the future, the function will crash

Expected behavior
It should return a String containing a human readable date

Additional context
Originally found this issue by configuring a sever to use a certificate that expired 40 years in the future. On the client side I tried to access the sender certificate and display information about it (subjectName, expirationDate, etc). The client would crash every time it got to this line: cert->getNotAfter().toDateTime(). If you run it in Debug mode you can see an assert failing in stftime.

image

@FabioOsorioMoreira FabioOsorioMoreira changed the title IceUtil::Time::toDateTime() crashes when used on dates 17+ years on the future IceUtil::Time::toDateTime() crashes when used on dates 17+ years in the future May 27, 2021
@pepone pepone added the bug label May 27, 2021
@pepone pepone added this to the 3.7.6 milestone May 27, 2021
@pepone
Copy link
Member

pepone commented May 27, 2021

Hi Fabio,

Thanks for the bug report, it is a problem with IceUtil::Time::toString implementation

time_t time = static_cast<long>(_usec / 1000000);

This cast is bogus, it should cast to time_t I will push a fix tomorrow with a test.

Cheers,
Jose

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

No branches or pull requests

2 participants