[CONTROLLER-806] ICMP.computeChecksum() may cause ArrayIndexOutOfBoundsException. Created: 11/Sep/14  Updated: 19/Oct/17  Resolved: 05/May/15

Status: Resolved
Project: controller
Component/s: adsal
Affects Version/s: Helium
Fix Version/s: None

Type: Bug
Reporter: Shigeru Yasuda Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


External issue ID: 1805

 Description   

ICMP.computeChecksum() causes ArrayIndexOutOfBoundsException if the size of
payload is odd.

java.lang.ArrayIndexOutOfBoundsException: 49
at org.opendaylight.controller.sal.packet.ICMP.computeChecksum(ICMP.java:199)
at org.opendaylight.controller.sal.packet.ICMP.postSerializeCustomOperation(ICMP.java:210)
at org.opendaylight.controller.sal.packet.Packet.serialize(Packet.java:194)

In this case the payload needs to be padded with a zero octet for computing
the checksum.

In addition, ICMP.computeChecksum() clears carry bits of the 16-bit checksum
incorrectly.

carry = (sum >> 16) & 0xFF; <===
finalSum = (sum & 0xFFFF) + carry;
return (short) ~((short) finalSum & 0xFFFF);

So it generates incorrect checksum if the 16-bit checksum overflows
more than 255 times.



 Comments   
Comment by Shigeru Yasuda [ 11/Sep/14 ]

I pushed a patch to fix ICMP checksum bugs.

https://git.opendaylight.org/gerrit/11024

Comment by Carol Sanders [ 05/May/15 ]

This bug is part of the project to Move all ADSAL associated component bugs to ADSAL.

Generated at Wed Feb 07 19:53:55 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.