+ 10

How unsafe is std::localtime?

Hiya! I was just completed an example on using streams and when I went to compile, Visual Studio complained that localtime was depreciated and considered unsafe and that I should consider using localtime_s instead. Can anyone tell me "how" unsafe it is? I.e Is it a massive weakness if I use this method. Should I listen, can people run arbitrary code through this or can they just give the program a new time? I also read that microsoft are the ones who have depreciated it, and that localtime is still standard c++. \Who is right? - So confused. -> when am I not though <- Here is the example: https://code.sololearn.com/c60QW3uVGxYd/#cpp

14th May 2017, 3:58 AM
jay
jay - avatar
3 odpowiedzi
+ 7
Yeah I saw those as well. I havent yet seen (or understand is probably a better description) what a person can do with it that makes it deemed unsafe. Is a buffer overflow possible? Or is only the returned time that is able to be changed?
14th May 2017, 4:06 AM
jay
jay - avatar
+ 6
FYI: Just for reference I found this: not sure if it will answer my question. But it may be interesting. (1 hour long presentation) - so yeah, I haven't finished watching it yet! "A C++14 approach to dates and times" https://www.youtube.com/watch?v=tzyGjOm8AKo
14th May 2017, 5:14 AM
jay
jay - avatar