+ 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
3 Respostas
+ 4
This is what I got from stack exchange, related to your question.
http://stackoverflow.com/questions/17982366/localtime-and-asctime-are-unsafe-but-the-safe-functions-dont-have-the-same-par
http://stackoverflow.com/questions/14386923/localtime-vs-localtime-s-and-appropriate-input-arguments
+ 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?
+ 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