2 ms·
This is part of the results from back in the early 00s when Windows XP was so ridiculously insecure that remote exploits appeared on a weekly basis and they sto
by whizzter 1y ago
This is part of the results from back in the early 00s when Windows XP was so ridiculously insecure that remote exploits appeared on a weekly basis and they stopped Longhorn development just to work on systematic issues.
Any function that had a target pointer for multiple items would get an size parameter, so f.ex. memcpy and strcpy have both dest buffer size and copy count, dest buffer size being smaller than count is a failure and produces an corresponding errno.
errno handling being the explicit return value is the change for Microsoft's fopen_s , probably to avoid multithreaded errno issues (is the global a thread local despite not being initially specified or do we risk race conditions).
To Microsoft's credit it seems that the standard bodies agreed on the replacements being improvements and they are now in C11, Microsoft just decided to push this for developers on Windows, probably since insecure programs affected their image and they've since that XP-era u-turn actually done a lot to fix what was an inherently insecure OS.
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-s-wfopen-s?view=msvc-170 https://learn.microsoft.com/en-us/cpp/c-runtime-library/refe...
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strcpy-s-wcscpy-s-mbscpy-s?view=msvc-170 https://learn.microsoft.com/en-us/cpp/c-runtime-library/refe...
https://en.cppreference.com/w/c/io/fopen.html https://en.cppreference.com/w/c/io/fopen.html