mirror of
https://github.com/coreutils/coreutils.git
synced 2024-11-24 10:23:31 +08:00
sort -u: fix a thread-race pointer corruption bug
* src/sort.c (write_unique): Save the entire "struct line", not just a pointer to one. Otherwise, with a multi-thread run, sometimes, with some inputs, fillbuf would would win a race and clobber a "saved->text" pointer in one thread just before it was dereferenced in a comparison in another thread. * NEWS (Bug fixes): Mention it.
This commit is contained in:
parent
43d1112d01
commit
3afda5f007
3
NEWS
3
NEWS
@ -7,6 +7,9 @@ GNU coreutils NEWS -*- outline -*-
|
||||
od now prints floating-point numbers without losing information, and
|
||||
it no longer omits spaces between floating-point columns in some cases.
|
||||
|
||||
sort -u with at least two threads could attempt to read through a
|
||||
corrupted pointer. [bug introduced in coreutils-8.6]
|
||||
|
||||
** New features
|
||||
|
||||
split accepts the --number option to generate a specific number of files.
|
||||
|
@ -3226,13 +3226,13 @@ queue_pop (struct merge_node_queue *queue)
|
||||
static void
|
||||
write_unique (struct line const *line, FILE *tfp, char const *temp_output)
|
||||
{
|
||||
static struct line const *saved = NULL;
|
||||
static struct line saved;
|
||||
|
||||
if (!unique)
|
||||
write_line (line, tfp, temp_output);
|
||||
else if (!saved || compare (line, saved))
|
||||
else if (!saved.text || compare (line, &saved))
|
||||
{
|
||||
saved = line;
|
||||
saved = *line;
|
||||
write_line (line, tfp, temp_output);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user