From e62ff8b6f68af6d7b70a8482839ab81a732fd6ac Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 19 Sep 2018 15:26:43 +0300 Subject: Fix agent to always skip invalid task response --- bbot/agent/agent.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bbot/agent/agent.cxx b/bbot/agent/agent.cxx index bc0b0c3..4760578 100644 --- a/bbot/agent/agent.cxx +++ b/bbot/agent/agent.cxx @@ -1046,6 +1046,8 @@ try { for (const string& u: controllers) { + task_response_manifest r; + try { http_curl c (trace, @@ -1075,7 +1077,7 @@ try if (!f) try { - tr = parse_manifest ( + r = parse_manifest ( c.in, u, "task response", false); } catch (const failed&) {f = true;} @@ -1091,20 +1093,22 @@ try continue; } - if (tr.challenge && !fingerprint) // Controller misbehaves. + if (r.challenge && !fingerprint) // Controller misbehaves. { - error << "unexpected challenge from " << u << ": " << *tr.challenge; + error << "unexpected challenge from " << u << ": " << *r.challenge; continue; } - if (!tr.session.empty ()) // Got a task. + if (!r.session.empty ()) // Got a task. { url = u; - task_manifest& t (*tr.task); + const task_manifest& t (*r.task); l2 ([&]{trace << "task for " << t.name << '/' << t.version << " " << "on " << t.machine << " " << "from " << url;}); + + tr = move (r); break; } } -- cgit v1.1