就像我们有 _stprintf
的安全版本,即 hp fortify bufferoverflow 的 stprintf_s
警告,那么我们可以使用什么来代替 wsprintf
()?我试过 wsprintf_s
,它不工作。
谁能解释一下 b/w _stprintf
和 wsprintf
的区别?或者我们可以使用 stprintf_s
作为 wsprintf
的安全版本。
最佳答案
选项记录在 wsprintf 下:
Note Do not use. Consider using one of the following functions instead: StringCbPrintf, StringCbPrintfEx, StringCchPrintf, or StringCchPrintfEx. See Security Considerations.
如果您更愿意使用更类似于 wsprintf
的安全函数, 去 swprintf_s或 _snwprintf_s .
_stprintf
是一个预处理器宏,它将调用映射到 ANSI 或 UNICODE 版本。映射表记录在 sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l :
_stprintf_s 的映射表:
关于c++ - wsprintf() 的安全版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33212449/