O_TRUNC missing, many places
Paul Fox
pgf at brightstareng.com
Fri Aug 25 20:39:49 UTC 2006
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 at brightstareng.com
More information about the busybox
mailing list