[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: textutils 2.0 sort bug: deletes incorrect /tmp files
From: |
Jim Meyering |
Subject: |
Re: textutils 2.0 sort bug: deletes incorrect /tmp files |
Date: |
19 May 2001 08:26:05 +0200 |
User-agent: |
Gnus/5.090003 (Oort Gnus v0.03) Emacs/21.0.104 |
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 <address@hidden> 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?