From 057c5dad4562ff77d66c95cf3633b53b94995a96 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 10 Dec 2001 13:03:31 +0000 Subject: [PATCH] perform some sanity checks on mail servers response. PR: 5273 (but probably doesn't fix it) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270106 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/mail/SmtpResponseReader.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/org/apache/tools/mail/SmtpResponseReader.java b/src/main/org/apache/tools/mail/SmtpResponseReader.java index a2a8f450c..2f220e49b 100644 --- a/src/main/org/apache/tools/mail/SmtpResponseReader.java +++ b/src/main/org/apache/tools/mail/SmtpResponseReader.java @@ -86,7 +86,7 @@ public class SmtpResponseReader { public String getResponse() throws IOException { result.setLength(0); String line = reader.readLine(); - if (line != null) { + if (line != null && line.length() >= 3) { result.append(line.substring(0, 3)); result.append(" "); } @@ -112,14 +112,16 @@ public class SmtpResponseReader { * Should we expect more input? */ protected boolean hasMoreLines(String line) { - return line.charAt(3) == '-'; + return line.length() > 3 && line.charAt(3) == '-'; } /** * Append the text from this line of the resonse. */ private void append(String line) { - result.append(line.substring(4)); - result.append(" "); + if (line.length() > 4) { + result.append(line.substring(4)); + result.append(" "); + } } }