From 7ac297a08274bf076aae86c58237a2d29f45460d Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 8 Jul 2012 11:24:23 +0200 Subject: [PATCH] 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 --- port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/port.c b/port.c index 10e9a03..223f627 100644 --- a/port.c +++ b/port.c @@ -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)