[PATCH 3/5] fs: do not call truncate for FILE_SIZE_STREAM sized files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 fs/fs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index c5b17e158a..1374286e62 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -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);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux