cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

datetime::to_string causes crash when m_interval is zero

Open bandrews-spirent opened this issue 6 years ago • 2 comments

Previously, if datetime was zero, to_string would return "1601-01-01T00:00:00Z" After upgrading to 2.10.14, sprintf_s throws with "Buffer too small, 0".

bandrews-spirent avatar Jan 21 '20 16:01 bandrews-spirent

I worked around it by adding

if (m_interval <= 0)
{
    return U("1601-01-01T00:00:00Z");
}

just before this line const int64_t epochAdjusted = static_cast<int64_t>(m_interval) - NtTo1900OffsetInterval;

bandrews-spirent avatar Jan 21 '20 16:01 bandrews-spirent

We are also hitting this issue while using C++ Azure storage sdk and work around for us is expensive/breaking change

https://github.com/Azure/azure-storage-cpp/issues/379

Any help would be appreciated.

surendernitj avatar Jan 12 '21 00:01 surendernitj