zeroing out memory

后端 未结 12 2036
無奈伤痛
無奈伤痛 2021-01-31 09:52

gcc 4.4.4 C89

I am just wondering what most C programmers do when they want to zero out memory.

For example, I have a buffer of 1024 bytes. Sometimes I do this:<

12条回答
  •  心在旅途
    2021-01-31 10:10

    One of the things that can happen if you don't initialize is that you run the risk of leaking sensitive information.

    Uninitialized memory may have something sensitive in it from a previous use of that memory. Maybe a password or crypto key or part of a private email. Your code may later transmit that buffer or struct somewhere, or write it to disk, and if you only partially filled it the rest of it still contains those previous contents. Certain secure systems require zeroizing buffers when an address space can contain sensitive information.

提交回复
热议问题