Catch negative literal sizes in imap responses

Check for negative sizes for literals so that we don't crash attempting
to create a negative sized array.

Bug:15834346
Change-Id: I1fbd9b86c807f1e97100fbfe52ef402a337bf655
This commit is contained in:
Jay Shrauner 2014-06-23 14:54:26 -07:00
parent 2eecdd1a50
commit 9adf186c5b
1 changed files with 3 additions and 0 deletions

View File

@ -438,6 +438,9 @@ public class ImapResponseParser {
} catch (NumberFormatException nfe) {
throw new MessagingException("Invalid length in literal");
}
if (size < 0) {
throw new MessagingException("Invalid negative length in literal");
}
expect('\r');
expect('\n');
FixedLengthInputStream in = new FixedLengthInputStream(mIn, size);