diff --git a/coreutils-dddoubleclose.patch b/coreutils-dddoubleclose.patch new file mode 100644 index 0000000..6a4edb1 --- /dev/null +++ b/coreutils-dddoubleclose.patch @@ -0,0 +1,45 @@ +diff -urNp coreutils-6.10-orig/src/dd.c coreutils-6.10/src/dd.c +--- coreutils-6.10-orig/src/dd.c 2007-12-06 14:22:42.000000000 +0100 ++++ coreutils-6.10/src/dd.c 2008-03-11 12:48:12.000000000 +0100 +@@ -391,6 +391,25 @@ static char const ebcdic_to_ascii[] = + '\070', '\071', '\372', '\373', '\374', '\375', '\376', '\377' + }; + ++/* True if we need to close the standard output *stream*. */ ++static bool close_stdout_required = true; ++ ++/* The only reason to close the standard output *stream* is if ++ parse_long_options fails (as it does for --help or --version). ++ In any other case, dd uses only the STDOUT_FILENO file descriptor, ++ and the "cleanup" function calls "close (STDOUT_FILENO)". ++ Closing the file descriptor and then letting the usual atexit-run ++ close_stdout function call "fclose (stdout)" would result in a ++ harmless failure of the close syscall (with errno EBADF). ++ This function serves solely to avoid the unnecessary close_stdout ++ call, once parse_long_options has succeeded. */ ++static void ++maybe_close_stdout (void) ++{ ++ if (close_stdout_required) ++ close_stdout (); ++} ++ + void + usage (int status) + { +@@ -1639,12 +1658,14 @@ main (int argc, char **argv) + textdomain (PACKAGE); + + /* Arrange to close stdout if parse_long_options exits. */ +- atexit (close_stdout); ++ atexit (maybe_close_stdout); + + page_size = getpagesize (); + + parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION, + usage, AUTHORS, (char const *) NULL); ++ close_stdout_required = false; ++ + if (getopt_long (argc, argv, "", NULL, NULL) != -1) + usage (EXIT_FAILURE); + diff --git a/coreutils.spec b/coreutils.spec index 368a5bd..65b779e 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: The GNU core utilities: a set of tools commonly used in shell scripts Name: coreutils Version: 6.10 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv3+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -19,6 +19,7 @@ Source203: coreutils-runuser-l.pamd # From upstream Patch1: coreutils-6.10-verbose.patch +Patch2: coreutils-dddoubleclose.patch # Our patches Patch100: coreutils-chgrp.patch @@ -97,6 +98,7 @@ cd %name-%version # From upstream %patch1 -p1 -b .verbose +%patch2 -p1 -b .doubleclose # Our patches %patch100 -p1 -b .chgrp @@ -293,6 +295,9 @@ fi /sbin/runuser %changelog +* Tue Mar 11 2008 Ondrej Vasik - 6.10-12 +- fixed harmless double close of stdout in dd(#436368) + * Thu Mar 6 2008 Ondrej Vasik - 6.10-11 - fixed broken order of params in stat(#435669)