3 ms·
What if the program never called free? Or if it crashed? A bad actor could intentionally crash a program, and then allocate lots of memory, then search for the
by perryizgr8 4y ago
What if the program never called free? Or if it crashed? A bad actor could intentionally crash a program, and then allocate lots of memory, then search for the password in the memory.
- Findecanor 4y agoAll modern operating systems will clear the physical memory before handing it from one process (crashed or not) to another.
- perryizgr8 4y agoIf that's true, then the entire premise of calloc is invalid, isn't it? Newly allocated memory would always be zeroed anyway by the OS. Then what are we even discussing?
- rightbyte 4y agoThere is a process local object pool in some implementations.
- butlerm 4y agomalloc is not a system call, it is a C library function. Modern operating systems clear memory when providing it to a process, but malloc implementations reuse the same memory locations previously used an arbitrary number of times within the process and normally do not clear memory when it is reused (within the process) for performance reasons.