[PATCH] Chained CPIOs writing to the same file bug

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

 



You can chain CPIOs together for the initramfs, but if two CPIOs write
to the same file, we don't clear the first before writing the second.
If the first is larger than the second, we end up with a mash of the
two.  Trivial patch below to fix this.

Signed-off-by: Michael Neuling <[email protected]>
---
 init/initramfs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6-linus/init/initramfs.c
===================================================================
--- linux-2.6-linus.orig/init/initramfs.c
+++ linux-2.6-linus/init/initramfs.c
@@ -250,7 +250,8 @@ static int __init do_name(void)
 		return 0;
 	if (S_ISREG(mode)) {
 		if (maybe_link() >= 0) {
-			wfd = sys_open(collected, O_WRONLY|O_CREAT, mode);
+			wfd = sys_open(collected, O_WRONLY|O_CREAT|O_TRUNC,
+				       mode);
 			if (wfd >= 0) {
 				sys_fchown(wfd, uid, gid);
 				sys_fchmod(wfd, mode);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux