Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: a newline added to separate a paragraph.

...

Reallocating memory using realloc() can have the same problem as freeing memory. The realloc() function de-allocates the old object and returns a pointer to a new object. Using realloc() to resize dynamic memory may inadvertently expose sensitive information, or it may allow heap inspection as described in Fortify Taxonomy: Software Security Errors [Fortify 2006] and NIST's Source Code Analysis Tool Functional Specification [Black 2007]. When

In this example, when realloc() is called, it may allocate a new, larger object, copy the contents of secret to this new object, free() the original object, and assign the newly allocated object to secret. However, the contents of the original object may remain in memory.

...