Equipment and method for preventing buffer overflow

The invention provides equipment and a method for preventing buffer overflow. The equipment comprises: a migration determining module used to calculate a threshold of a free space in a local buffer area and calculate a actual free space in the current local buffer area, wherein the threshold of the free space is compared with the actual free space, and if the threshold of free space is greater than the actual free space, then the need to carry out temporary files migration is determined; a file migration module, by which the temporary files are migrated to a predetermined target directory, and soft links linking to the migrated temporary files are established in the directory of the local buffer area; and a buffer monitoring module which monitors operation on temporary files in the local buffer area by application tasks, when an writing operation upon the temporary files in the local buffer area is detected the migration determining module is controlled to determine whether to carry out temporary file migration or not, if the need to carry out temporary file migration is determined, then the file migration module is controlled to carry out temporary file migration.