Buffer overflow
When a program writes more data into a memory area than it can hold, spilling over and overwriting nearby memory. This can crash the program or let an attacker run their own code.
Understanding Buffer overflow in Years 9–10 Digital Systems
What it does: The buffer holds 10 items but 20 are written, so the extra 10 spill into neighbouring memory. This is a buffer overflow and may cause a crash. Overwriting nearby memory can corrupt data the program needs, so a crash is a common result. Bounds checking means testing that the data length is within the buffer's size before writing. Checking after the write is too late.
Common mistakes: The call copies up to 20 bytes into name, which only holds 8, so it overflows the buffer. The copy length must fit the buffer, for example 7 plus the end marker. nums has indexes 0 to 4. Using <= 5 writes to nums[5], one past the end of the array. The loop condition should be i < 5.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 41–69) and word search (Modules 41–79).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
buffer overflowFill in the Blanks
Spot the Error
Student with a class code? Join your class →