Memcpy() in secure programming?

前端 未结 10 2080
天命终不由人
天命终不由人 2020-12-08 16:34

I recently stumbled across an article that claims Microsoft is banning the memcpy() function in its secure programming shops. I understand the vulnerabilities i

10条回答
  •  执笔经年
    2020-12-08 16:50

    If you're using older versions, like C99 or C++98, or on Solaris, you can't use memcpy_s, unless you have the Safe C library installed.

    memcpy_s() is a Microsoft-specific implementation that doesn't exist on non-MS implementations, including ANSI, prior to C11, per their own standards.

    I'll leave the pro-MS and anti-MS stuff aside, because it's irrelevant.

    memmove() is a better solution anyway since it addressed the overlap issue. memmove_s() is more robust, but again, only if you're in C11 or later.

提交回复
热议问题