Buffer is a finite amount of memory, which holds the data temporarily. A buffer overflow or buffer overrun occurs when that finite amount of buffer memory is exceeded, basically running out of memory. This happens when the program or a file tries to store more data then that it is intended to hold. The extra information which doesn’t fits in the buffer can overflow into adjacent buffers, damaging or even corrupting the data stored in that location.
The buffer overflow can occur accidentally or on purpose. A fault while coding a program can cause buffer overflow, for that reason a program must be tested in all possible ways, so these kind of situations can be avoided. An attacker can take advantage of this technique. If the attacker finds a ways to send a particular file or program to the destination computer which exceeds the buffers capacity, the extra data may contain malicious instruction, which will get triggered and perform a particular action, programmed by the attacker.