Secure-Coding Takeaways
- Bounds are your job in C/C++: validate every length; favor safe APIs and length-checked copies over
strcpy/memcpywith attacker sizes. - Kill lifetime bugs: after
free/kfree, null the pointer; own object lifetimes clearly (RAII, reference counts) to prevent UAF and double free. - Watch integers: size and index math is where overflows become memory corruption — check before you allocate or copy.
- Defense in depth: compile with modern mitigations on, keep them on, and never rely on a single one.
- Prefer memory-safe languages for new code where you can (Rust, Go); isolate and minimize unsafe native surface.
Key Takeaway
Exploitation knowledge is defensive knowledge: you now know exactly which mistakes attackers hunt for.