diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c index e4c981315922b..07eeee3913784 100644 --- a/fs/romfs/fs_romfs.c +++ b/fs/romfs/fs_romfs.c @@ -563,6 +563,13 @@ static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence) goto errout_with_lock; } + if (position < 0) + { + ferr("ERROR: Invalid position: %jd\n", (intmax_t)position); + ret = -EINVAL; + goto errout_with_lock; + } + /* Limit positions to the end of the file. */ if (position > rf->rf_size)