NullPointerException in StringMsgParser

Ryan Mitchell <[email protected]> Sat, 02 Jun 2007 11:06:12 -0700
Newsgroups gmane.comp.voip.nist-sip
Message-ID <[email protected]>
A Sipura 2100 of mine sends a malformed OPTIONS request to keep a
firewall pinhole open.  Or better put, unformed: the udp packet content
is comprised of 7 bytes: O,P,T,I,O,N,S.

Anyway, this causes NullPointerException trying to parse it.  Attached patch
fixes it.  Let me know if it helps.

--Ryan

-- Ryan Mitchell <[email protected]> Telecom Logic, LLC 503-943-2980

_______________________________________________
nist-sip mailing list
[email protected]
http://www-x.antd.nist.gov/mailman/listinfo/nist-sip
StringMsgParser.diff (text/x-patch, 977 B)
--- gov/nist/javax/sip/parser/StringMsgParser.java.orig	2007-06-02 10:50:36.000000000 -0700
+++ gov/nist/javax/sip/parser/StringMsgParser.java	2007-06-02 10:49:19.000000000 -0700
@@ -170,7 +170,7 @@
 
 			if (currentLine.length() == 0) {
 				// Last header line, process the previous buffered header.
-				if (currentHeader != null) {
+				if (currentHeader != null && message != null) {
 					processHeader(currentHeader, message);
 				}
 			}
@@ -187,7 +187,7 @@
 						currentHeader += currentLine.substring(1);
 					}
 					else {
-						if (currentHeader != null) {
+						if (currentHeader != null && message != null) {
 							processHeader(currentHeader, message);
 						}
 						currentHeader = currentLine;
@@ -203,6 +203,8 @@
 			isFirstLine = false;
 		}
 		while (currentLine.length() > 0);
+
+        if (message == null) throw new ParseException("Bad message", 0);
 		
 		message.setSize(i);
 		
@@ -679,4 +681,4 @@
 
 	}
 
-}
\ No newline at end of file
+}