[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    O_TRUNC missing, many places
From:       Paul Fox <pgf () brightstareng ! com>
Date:       2006-08-25 20:39:49
Message-ID: 9334.1156538389 () brightstareng ! com
[Download RAW message or body]

hi --

busybox unzip will happily overwrite just part of a file (if the new
file is shorter than the old file) because it needs this patch:
    
Index: archival/unzip.c
===================================================================
--- archival/unzip.c	(revision 15996)
+++ archival/unzip.c	(working copy)
@@ -333,7 +333,7 @@
 			overwrite = o_always;
 		case 'y': /* Open file and fall into unzip */
 			unzip_create_leading_dirs(dst_fn);
-			dst_fd = xopen3(dst_fn, O_WRONLY | O_CREAT, 0777);
+			dst_fd = xopen3(dst_fn, O_WRONLY | O_CREAT | O_TRUNC, 0777);
 		case -1: /* Unzip */
 			if (verbosity == v_normal) {
 				printf("  inflating: %s\n", dst_fn);


a quick skim of the rest of busybox says that this might also be
a problem in some other places:  gzip, gunzip, and bunzip2 looked
suspicious.  tar seems okay, but only because it unlinks the file
before opening it.  (that unlinking is optional in gnu tar -- if
we were to implement that option (in order to allow preservation of
hard links to the target file), busybox tar's open flags would
need to change.)

i don't have time right now to investigate all the cases where
O_TRUNC looks like it might be missing, but i also didn't want to
delay reporting this.

paul
=---------------------
 paul fox, pgf@brightstareng.com
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic