From the course: Secure Coding in C

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Clearing data after use

Clearing data after use - C Tutorial

From the course: Secure Coding in C

Start my 1-month free trial

Clearing data after use

- [Instructor] Sensitive data input into a program must be cleared after it's used. You don't want the information working in memory, so in this code, a five-digit PIN is required. The PIN is stored in another file, specified as access text on line nine. This method is secure, more secure than hard coding the PIN right here, but at about line 42 or so in the code, the PIN is stored in memory, along with the user's input. The issue is that a core dump or a memory scanning software can detect this data, especially if it isn't erased right away. In this improvement to the code, down at line 46, both the input retrieved, and PIN, are zeroed out. The buffers are filled with null characters. The program still works, but at this point however, the authentication data has been scrubbed from memory. Always scrub the buffer in this manner after important data has been used. For any sensitive data in your code that you don't want…

Contents