GNU bug report logs - #7370
[PATCH] csplit: diagnose file counter wraparound

Previous Next

Package: coreutils;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Thu, 11 Nov 2010 08:24:02 UTC

Severity: normal

Tags: patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7370 in the body.
You can then email your comments to 7370 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7370; Package coreutils. (Thu, 11 Nov 2010 08:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert <at> cs.ucla.edu>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 11 Nov 2010 08:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: bug-coreutils <at> gnu.org
Subject: [PATCH] csplit: diagnose file counter wraparound
Date: Thu, 11 Nov 2010 00:28:35 -0800
(Ordinarily I guess I'd just install something like this, but since
we're near a release I held off.  The bug is unlikely in practice.)

* src/csplit.c (create_output_file): Detect overflow when the
file counter wraps around, and exit with a diagnostic.  Formerly
the code silently wrapped around and wrote to the wrong file,
losing output data.
---
 src/csplit.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/csplit.c b/src/csplit.c
index 531e492..9505076 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -917,19 +917,27 @@ make_filename (unsigned int num)
 static void
 create_output_file (void)
 {
-  sigset_t oldset;
   bool fopen_ok;
   int fopen_errno;
 
   output_filename = make_filename (files_created);
 
-  /* Create the output file in a critical section, to avoid races.  */
-  sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
-  output_stream = fopen (output_filename, "w");
-  fopen_ok = (output_stream != NULL);
-  fopen_errno = errno;
-  files_created += fopen_ok;
-  sigprocmask (SIG_SETMASK, &oldset, NULL);
+  if (files_created == UINT_MAX)
+    {
+      fopen_ok = false;
+      fopen_errno = EOVERFLOW;
+    }
+  else
+    {
+      /* Create the output file in a critical section, to avoid races.  */
+      sigset_t oldset;
+      sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
+      output_stream = fopen (output_filename, "w");
+      fopen_ok = (output_stream != NULL);
+      fopen_errno = errno;
+      files_created += fopen_ok;
+      sigprocmask (SIG_SETMASK, &oldset, NULL);
+    }
 
   if (! fopen_ok)
     {
-- 
1.7.2





Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sun, 17 Apr 2011 09:00:04 GMT) Full text and rfc822 format available.

Notification sent to Paul Eggert <eggert <at> cs.ucla.edu>:
bug acknowledged by developer. (Sun, 17 Apr 2011 09:00:05 GMT) Full text and rfc822 format available.

Message #10 received at 7370-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: 7370-done <at> debbugs.gnu.org
Subject: Re: bug#7370: [PATCH] csplit: diagnose file counter wraparound
Date: Sun, 17 Apr 2011 10:59:32 +0200
Paul Eggert wrote:
> (Ordinarily I guess I'd just install something like this, but since
> we're near a release I held off.  The bug is unlikely in practice.)
>
> * src/csplit.c (create_output_file): Detect overflow when the
> file counter wraps around, and exit with a diagnostic.  Formerly
> the code silently wrapped around and wrote to the wrong file,
> losing output data.

This was pushed in December.  Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 15 May 2011 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 124 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.