parser problem
"Akito Nozaki" <[email protected]> Wed, 9 May 2007 10:52:54 -0700
| Newsgroups | gmane.comp.voip.nist-sip |
|---|---|
| Message-ID | <FC5ED86A8748084CB2C8E230C7CE713B1C8313@exchange1.windows.deltel.com> |
I finally got around to making a patch file. This fixes the parser from successfully finish parsing if the body does not match the body content length. One thing I don't know is if the body is shorter then the content length... is it a fatal error? I know this is usually not a problem, but can happen. Thanks Akito _______________________________________________ nist-sip mailing list [email protected] http://www-x.antd.nist.gov/mailman/listinfo/nist-sip
parser_patch.diff
(application/octet-stream, 879 B)
? parser_patch.diff
Index: src/gov/nist/javax/sip/parser/StringMsgParser.java
===================================================================
RCS file: /cvs/jain-sip/src/gov/nist/javax/sip/parser/StringMsgParser.java,v
retrieving revision 1.19
diff -u -b -r1.19 StringMsgParser.java
--- src/gov/nist/javax/sip/parser/StringMsgParser.java 6 Feb 2007 16:40:03 -0000 1.19
+++ src/gov/nist/javax/sip/parser/StringMsgParser.java 9 May 2007 17:31:00 -0000
@@ -315,6 +315,11 @@
if (readBody && message.getContentLength() != null &&
message.getContentLength().getContentLength() != 0) {
+ int bodyLength = message.getContentLength().getContentLength();
+ int bufferLeft = msgString.length() - i;
+ if(bodyLength > bufferLeft)
+ throw new ParseException("Bad body content.", 0);
+
String body = msgString.substring(i);
message.setMessageContent(body);
}