WCU / Cybersecurity
~/CSC 472/Class 03/KP 04
Class 03 · KP 04 / 17

The Usual Suspects (Unbounded Copies)

  • gets(buf) — reads a line with no size limit. Never safe.
  • strcpy(dst, src) — copies until a NUL byte, ignores dst size.
  • sprintf(buf, fmt, ...) — formats with no length bound.
  • strcat / memcpy with an attacker-controlled length.
  • read(fd, buf, n) with the wrong n (bigger than buf).
  • scanf("%s", buf)%s with no field width.
Key Takeaway

The pattern to flag in review: a copy whose length comes from input or is a constant larger than the destination.