Memcpy() in secure programming?

前端 未结 10 2102
天命终不由人
天命终不由人 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条回答
  •  旧时难觅i
    2020-12-08 16:53

    The article itself describes a safer alternative: memcpy_s, which requires you to specify the maximum length of the target. When that number is provided independent of the amount of bytes to copy, it acts as a barrier to prevent buffer overflow. Of course, you can abuse that by giving the same number to both.

提交回复
热议问题