diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-02-04 12:38:55 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-02-06 08:31:13 +0100 |
commit | 20eea939a6fef5a02d55e83b997cd8c86607d83f (patch) | |
tree | 3bd5f141c0b79af338cd678fd00d2174c703fadb | |
parent | 97e7c77a70ba37619d1883d224f9e218b1755b20 (diff) | |
download | barebox-20eea939a6fef5a02d55e83b997cd8c86607d83f.tar.gz barebox-20eea939a6fef5a02d55e83b997cd8c86607d83f.tar.xz |
fs: do not call truncate for FILE_SIZE_STREAM sized files
open_and_lseek() increases the file size when the file is opened in
write mode and scrolled past the files end. This fails badly on /dev/mem
because loff_t which we use for the file size is signed variable, which
is used as an unsigned variable in /dev/mem. To catch this case do not
try to truncate FILE_SIZE_STREAM sized files.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/fs.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -213,6 +213,9 @@ int ftruncate(int fd, loff_t length) f = &files[fd]; + if (f->size == FILE_SIZE_STREAM) + return 0; + fsdrv = f->fsdev->driver; ret = fsdrv->truncate(&f->fsdev->dev, f, length); |