Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.
Note: This is not a complete solution, since many buffer overflows are not related to strings.
Phases: Operation; Build and Compilation
Strategy: Environment Hardening