Thanks for the report and patch.

That part of sort has been rewritten in recent test releases.
If you find that the latest version still has a problem,
please report it.

This is the latest test release:

  ftp://alpha.gnu.org/gnu/fetish/textutils-2.0.14.tar.gz



Ketil Froyn <[EMAIL PROTECTED]> wrote:
| I have found a bug in sort. The bug is that if sort encounters a file
| that already exists in the xtmpfopen() function, open() fails (because of
| the O_EXCL flag). When cleanup() is called now, sort will wrongfully
| delete the file that it encountered. I would like to propose this patch:
|
| diff -urN ../textutils-2.0/src/sort.c ./src/sort.c
|
| --- ../textutils-2.0/src/sort.c Thu Aug  5 09:42:49 1999
| +++ ./src/sort.c        Wed May 16 17:52:17 2001
| @@ -327,6 +327,7 @@
|  {
|    FILE *fp;
|    int fd;
| +  struct tempnode *node;
|
|    /*  Open temporary file exclusively, to foil a common
|        denial-of-service attack.  */
| @@ -334,6 +335,10 @@
|    if (fd < 0 || (fp = fdopen (fd, "w")) == NULL)
|      {
|        error (0, errno, "%s", file);
| +      node = temphead.next;
| +      temphead.next = node->next;
| +      free(node->text);
| +      free(node);
|        cleanup ();
|        exit (SORT_FAILURE);
|      }
|
|
| Also, it doesn't really need to be a fatal error if a file can't be
| opened, does it?

_______________________________________________
Bug-textutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-textutils

Reply via email to