Browse Source

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
master
Stefan Bodewig 23 years ago
parent
commit
057c5dad45
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      src/main/org/apache/tools/mail/SmtpResponseReader.java

+ 6
- 4
src/main/org/apache/tools/mail/SmtpResponseReader.java View File

@@ -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(" ");
}
}
}

Loading…
Cancel
Save