mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/9] UML - Fix off-by-one bug in VM file creation
@ 2006-06-29 21:36 Jeff Dike
  0 siblings, 0 replies; only message in thread
From: Jeff Dike @ 2006-06-29 21:36 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, user-mode-linux-devel

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>

Index: linux-2.6.17/arch/um/os-Linux/mem.c
===================================================================
--- linux-2.6.17.orig/arch/um/os-Linux/mem.c	2006-06-29 10:42:11.000000000 -0400
+++ linux-2.6.17/arch/um/os-Linux/mem.c	2006-06-29 11:42:23.000000000 -0400
@@ -210,8 +210,11 @@ int create_tmp_file(unsigned long long l
 		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);
 	}
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-29 21:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-29 21:36 [PATCH 2/9] UML - Fix off-by-one bug in VM file creation Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®