Skip to content

Commit

Permalink
[PATCH] uml: fix off-by-one bug in VM file creation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed Jun 30, 2006
1 parent c2b7a4b commit 190f493
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions arch/um/os-Linux/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 190f493

Please sign in to comment.