Correct infinite loop in base parser 11/78511/2
authorOlivier Dugeon <olivier.dugeon@orange.com>
Wed, 28 Nov 2018 13:15:28 +0000 (14:15 +0100)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Fri, 7 Dec 2018 05:48:06 +0000 (05:48 +0000)
commit6280854947f20548ef9849937d530eddcee9be3d
tree77c9513291a4c90c5816b9b728fd409bcddab294
parent1a27f8c41740403ccfc03b6c1e18655f607b4b0d
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>
(cherry picked from commit 367772ab24152242563a16d120441b353315c49f)
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]