From b3636de7add8c6a5a19d58dcf4792d9abbeaf1c3 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Wed, 7 Feb 2018 15:48:08 -0500 Subject: [PATCH] namesys: discard records with invalid EOL in record selection License: MIT Signed-off-by: Dirk McCormick --- namesys/selector.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/namesys/selector.go b/namesys/selector.go index 53c712d1ceb2..aebfb1533ae2 100644 --- a/namesys/selector.go +++ b/namesys/selector.go @@ -35,23 +35,17 @@ func selectRecord(recs []*pb.IpnsEntry, vals [][]byte) (int, error) { if r == nil || r.GetSequence() < bestSeq { continue } + rt, err := u.ParseRFC3339(string(r.GetValidity())) + if err != nil { + log.Errorf("failed to parse ipns record EOL %s", r.GetValidity()) + continue + } if besti == -1 || r.GetSequence() > bestSeq { bestSeq = r.GetSequence() besti = i } else if r.GetSequence() == bestSeq { - rt, err := u.ParseRFC3339(string(r.GetValidity())) - if err != nil { - log.Errorf("failed to parse ipns record EOL %s", r.GetValidity()) - continue - } - - bestt, err := u.ParseRFC3339(string(recs[besti].GetValidity())) - if err != nil { - log.Errorf("failed to parse ipns record EOL %s", recs[besti].GetValidity()) - continue - } - + bestt, _ := u.ParseRFC3339(string(recs[besti].GetValidity())) if rt.After(bestt) { besti = i } else if rt == bestt {