ftruncate: sanity check for parameter:length

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-10-31 12:29:59 +08:00 committed by Abdelatif Guettouche
parent 33d236121f
commit e5f8acab97

View file

@ -155,7 +155,12 @@ int file_truncate(FAR struct file *filep, off_t length)
int ftruncate(int fd, off_t length)
{
FAR struct file *filep;
int ret;
int ret = -EINVAL;
if (length < 0)
{
goto errout;
}
/* Get the file structure corresponding to the file descriptor. */