Skip to main content
Definition Website Computer and Technology

Buffer Overflow

Subject: Computer and Technology noun /ˈbʌf.ər ˈoʊ.vər.floʊ/ 1 definition

  1. Definition (noun)

    Entry #114 · Updated

    A Buffer Overflow is a memory-safety vulnerability that occurs when a program writes more data into a fixed-size, contiguous region of memory than it was allocated to hold. When bounds checking is omitted or miscalculated—commonly in low-level languages such as C and C++—excess bytes spill past the buffer's boundary and overwrite adjacent memory locations. Depending on the surrounding memory layout, that out-of-bounds write can corrupt program data, crash the process, or overwrite control structures such as return addresses and function pointers to enable arbitrary code execution.

    Common Types

    • Stack-Based Buffer Overflow: Occurs when an oversized write into a local buffer on the call stack overwrites neighboring local variables, saved frame pointers, or the function's return address to hijack control flow.

    • Heap-Based Buffer Overflow: Corrupts dynamically allocated memory on the heap by writing past a chunk's boundary, overwriting adjacent heap objects, function pointers, or allocator metadata.

    • Off-by-One Overflow: Arises when a boundary calculation error writes a single extra byte—such as a trailing null terminator—past the allocated buffer, potentially altering an adjacent length field or frame pointer.

    • Data-Segment Buffer Overflow: Overwrites fixed-size global or static buffers stored outside the stack and heap, corrupting neighboring static variables, configuration flags, or global function pointers.

    Example

    A C network daemon allocates a 64-byte stack array char username[64] and copies an incoming login string into it with strcpy() without validating the input length. When a client submits a 96-byte payload, the extra 32 bytes spill past the array boundary, overwriting the saved return address on the stack and redirecting execution when the function returns.