summaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-06-30 01:55:55 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-30 11:25:37 -0700
commit190f4939222b8c07cd62a20e1ce0c7a97fffde99 (patch)
treef3de1035774a1c6358231903d847f1313db7bf0b /arch/um/os-Linux
parentc2b7a4bb30008dc256d63802e02b6fb950958443 (diff)
downloadop-kernel-dev-190f4939222b8c07cd62a20e1ce0c7a97fffde99.zip
op-kernel-dev-190f4939222b8c07cd62a20e1ce0c7a97fffde99.tar.gz
[PATCH] uml: fix off-by-one bug in VM file creation
Fix an off-by-one bug in temp file creation. Seeking to the desired length and writing a byte resulted in the file being one byte longer than expected. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r--arch/um/os-Linux/mem.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index d24d1a9..560c806 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -210,8 +210,11 @@ int create_tmp_file(unsigned long long len)
exit(1);
}
- if (lseek64(fd, len, SEEK_SET) < 0) {
- perror("os_seek_file");
+ /* Seek to len - 1 because writing a character there will
+ * increase the file size by one byte, to the desired length.
+ */
+ if (lseek64(fd, len - 1, SEEK_SET) < 0) {
+ perror("os_seek_file");
exit(1);
}
OpenPOWER on IntegriCloud