The following code contains a bug, can you spot it?
class Program { private Timer nextcheck; public event EventHandler ServerSigFailed; static void Main(string[] args) { var program = new Program(); if(program.ValidateServerSig() == false) return; program.DoOtherStuff(); } public bool ValidateServerSig() { nextcheck = new Timer(state => ValidateServerSig()); var response = DoRequest("http://remote-srv/signature"); if(response.Failed) { var copy = ServerSigFailed; if(copy!=null) copy(this, EventArgs.Empty); return false; } var result = Utils.CheckPublic KeySignatureMatches(response); if(result.Valid) if(response.Failed) { var copy = ServerSigFailed; if(copy!=null) copy(this, EventArgs.Empty); return false; } // setup next check nextcheck.Change(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); return true; } }
What are the implications of this bug?
Reference: | Find the bug – The case of the degrading system from our NCG partner Oren Eini at the Ayende @ Rahien blog. |