There is a bug in this code. Can you spot it?
private string ReceiveLine() { const int bufferLength=1024; byte[] buffer=new byte[bufferLength+1]; // extra char for null terminator StringBuilder message=new StringBuilder(bufferLength); int bytesRead; for(;;) { bytesRead=socket.Receive(buffer, bufferLength, 0); if (bytesRead==0) break; // add null terminator buffer[bytesRead]=0;// conver char array to string message.Append(Encoding.ASCII.GetChars(buffer, 0, bytesRead)); if (buffer[bytesRead-1]==10) break; } string tmp=message.ToString(); if(tmp.StartsWith(POS_STAT_IND)==false) throw new Exception("Received negative response from POP3 server"); return tmp; }
![]()
