Correct infinite loop in base parser 61/78261/11
authorOlivier Dugeon <olivier.dugeon@orange.com>
Wed, 28 Nov 2018 13:15:28 +0000 (14:15 +0100)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Thu, 6 Dec 2018 16:23:35 +0000 (16:23 +0000)
commit367772ab24152242563a16d120441b353315c49f
tree2f7b474a97ecbb048673a6d7d196fdebc1ead857
parentbd68371f9f19d5ef46e07d6f89179799f5414fe0
Correct infinite loop in base parser

When sending a PCReply message with more than one ERO object, as per RFC540,
the PCEP base parser start infinite loop and stop with a java heap exception.

The problem is located in PCEPReplyMessageParser.java (pcep-base-parser
package) at line 217 in handleEro() method. handleEro() is called with the first
ERO object and remaining object to parse metrics associated with this ERO. The
parsing is done by parserPath() method, but this method expect to find only
metrics object. When a second ERO follow the last metric of the first ERO,
parsePath() method do nothing and handleEro() method start infinite loop at line
220 as the object list is not empty and parsePath() will not empty it.

This patch replace handleEro() method by handleEros() in order to parse
correctly multiple ERO in PCReply message. It also add a new test in
PCEPValidatorTest.java class: testPCRepMsgWithTwoEros() in order to verify
that a PCPep Message with two EROs is correctly parse.

JIRA: BGPCEP-851 PCEP base parser is unable to handle multiple ERO

Change-Id: I194b7cbb347a3b377e7b3000f93ef1d21a86f39a
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/message/PCEPReplyMessageParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPValidatorTest.java
pcep/impl/src/test/resources/PCRep.7.bin [new file with mode: 0644]