summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-02-19 08:52:53 +0000
committerJim Meyering <jim@meyering.net>2001-02-19 08:52:53 +0000
commit5af9b0048f103248f4973b8362e83f04ce524201 (patch)
tree40d948e0ed4cf608bdf82396b91aa6f0860032e7
parent9758a4d87adbdb8c4481a2263855e577e15f56a3 (diff)
downloadcoreutils-5af9b0048f103248f4973b8362e83f04ce524201.tar.xz
Fix a race condition: freed storage accessed during a signal handler.
(struct tempnode.next): Now volatile. (zaptemp): Free the file name after removing it from the temp list, not before, because a signal can arrive between the two actions and cleanup () traverses the list.
-rw-r--r--src/sort.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/sort.c b/src/sort.c
index affde7b21..5672b5bbb 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -343,7 +343,7 @@ Set LC_ALL=C to get the traditional sort order that uses native byte values.\n\
static struct tempnode
{
char *name;
- struct tempnode *next;
+ struct tempnode * volatile next;
} temphead;
/* Clean up any remaining temporary files. */
@@ -503,8 +503,8 @@ zaptemp (const char *name)
{
temp = node->next;
unlink (temp->name);
- free (temp->name);
node->next = temp->next;
+ free (temp->name);
free ((char *) temp);
}
}