메모리 안전성Memory safety
CWE-787 경계 밖 쓰기Out-of-bounds Write
버퍼 경계를 넘어 데이터를 쓰는 결함(스택/힙 오버플로 포함).Data is written past the end (or before the start) of a buffer.
근본 원인 패턴Root-cause pattern
길이 계산과 실제 복사량이 어긋난다: 신뢰할 수 없는 길이 필드, off-by-one, 정수 오버플로로 작아진 할당 크기.The computed length and the copied length disagree: untrusted length fields, off-by-one, or an allocation shrunk by integer overflow.
전형적인 패치Typical fix
복사 전 경계 검사 추가, 크기 계산에 오버플로 검사, 안전한 API 사용.Add bounds checks before copying, overflow-checked size math, safer APIs.