summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
f3bdffc)
ISSUE:
ICMP.computeChecksum() incorrectly assumes rawPayload is always present
while determining the lenght of the ICMP packet byte stream on which
computing the checksum.
Change-Id: I41c1e0509f21a2bbb0a5ec6df038ed18a81f327a
Signed-off-by: Alessandro Boch <aboch@cisco.com>
short computeChecksum(byte[] data, int start) {
int sum = 0, carry = 0, finalSum = 0;
int wordData;
short computeChecksum(byte[] data, int start) {
int sum = 0, carry = 0, finalSum = 0;
int wordData;
- int end = start + this.getHeaderSize() / NetUtils.NumBitsInAByte
- + rawPayload.length;
- int checksumStartByte = start + getfieldOffset(CHECKSUM)
- / NetUtils.NumBitsInAByte;
+ int end = start + this.getHeaderSize() / NetUtils.NumBitsInAByte;
+ if (rawPayload != null) {
+ end += rawPayload.length;
+ }
+ int checksumStartByte = start + getfieldOffset(CHECKSUM) / NetUtils.NumBitsInAByte;
for (int i = start; i <= (end - 1); i = i + 2) {
// Skip, if the current bytes are checkSum bytes
for (int i = start; i <= (end - 1); i = i + 2) {
// Skip, if the current bytes are checkSum bytes