Fix unsafe reference of foreign master announce message.

When computing a port's best foreign master, we make use of a message
reference that possibly might have been dropped by calling msg_put in
the fc_prune subroutine. This commit fixes the issue by copying the
needed data from the message before pruning.

[ Actually, since msg_put only places the message into a list without
  altering its contents, there was no ill effect. But using a message
  after having released it is just plain wrong. ]

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-07-08 11:24:23 +02:00
parent 3616692203
commit 7ac297a082
1 changed files with 2 additions and 2 deletions

4
port.c
View File

@ -1141,13 +1141,13 @@ struct foreign_clock *port_compute_best(struct port *p)
if (!tmp)
continue;
announce_to_dataset(tmp, p->clock, &fc->dataset);
fc_prune(fc);
if (fc->n_messages < FOREIGN_MASTER_THRESHOLD)
continue;
announce_to_dataset(tmp, p->clock, &fc->dataset);
if (!p->best)
p->best = fc;
else if (dscmp(&fc->dataset, &p->best->dataset) > 0)