zoukankan      html  css  js  c++  java
  • [转]Unsafe at any speed: Memcpy() banished in Redmond

    原文地址:http://www.theregister.co.uk/2009/05/15/microsoft_banishes_memcpy/

    Memcpy() and brethren, your days are numbered. At least in development shops that aspire to secure coding.

    Microsoft plans to formally banish the popular programming function that's been responsible for an untold number of security vulnerabilities over the years, not just in Windows but in countless other applications based on the C language. Effective later this year, Microsoft will add memcpy(), CopyMemory(), and RtlCopyMemory() to its list of function calls banned under its secure development lifecycle.

    Memcpy has long served as a basic staple of C-based languages, providing a simple way to copy the contents from one chunk of memory to another. Its drawback comes when the source to be copied contains more bytes than its destination, creating overflows that present attackers with opportunities to remotely execute code in the underlying application.

    "That's definitely one of those notoriously dangerous C commands," said Johannes Ullrich, CTO of the SANS Institute, who teaches secure coding classes to developers. He likened memcpy() to other risky functions such as strcpy() and strcat(), which Microsoft has already banned after exacting untold misery over the years.

    Developers who want to be SDL compliant will instead have to replace memcpy() functions with memcpy_s, a newer command that takes an additional parameter delineating the size of the destination buffer. The command is already supported in Microsoft's Visual C++, but according to Ullrich, native support doesn't yet seem to be available in the GCC compiler. (This evidently can easily be worked around, according to this discussion. Readers who know other approaches are encouraged to leave a comment.)

    A Microsoft blog entry that heralded the planned change suggests modifying common header files so compilers issue a warning each time the banned function is used.

    It also wondered aloud when "Larry, Steve, and Linus" plan to issue similar security edicts in their products. It's a question worth asking. ®

  • 相关阅读:
    栈和队列
    绪论
    抽象数据类型和python类
    《黑马程序员》流程控制(顺序结构,选择结构,循环结构)(C语言)
    《黑马程序员》C语言中的基本运算(C语言)
    《黑马程序员》C语言中的基本数据类型 (C语言)
    《黑马程序员》 关键字、标示符、注释(C语言)
    获取图片
    文件路径
    文件上传
  • 原文地址:https://www.cnblogs.com/cxun/p/1459172.html
Copyright © 2011-2022 走看看