The stack overflow refers to the situation that the execution stack goes beyond the space reserved for the executing program, while that buffer overflow means that a program writes data beyond the memory allocated for a buffer. The stack overflow is a specific type of buffer overflow.