EEPROM: prevent writes past end of device. From Sébastien Lorquet

This commit is contained in:
Gregory Nutt 2014-11-27 07:59:43 -06:00
parent 084fe072fc
commit b29925a63b

View File

@ -642,6 +642,13 @@ static ssize_t ee25xx_write(FAR struct file *filep, FAR const char *buffer,
return ret; return ret;
} }
/* Forbid writes past the end of the device */
if (filep->f_pos >= eedev->size)
{
return -EFBIG;
}
/* Clamp len to avoid crossing the end of the memory */ /* Clamp len to avoid crossing the end of the memory */
if ( (len + filep->f_pos) > eedev->size) if ( (len + filep->f_pos) > eedev->size)