Skip to content

Commit

Permalink
[SCTP]: Fix sctp_rcv_ootb() to handle the last chunk of a packet corr…
Browse files Browse the repository at this point in the history
…ectly.

Signed-off-by: Tsutomu Fujii <t-fujii@nb.jp.nec.com>
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
  • Loading branch information
Tsutomu Fujii authored and Sridhar Samudrala committed Jan 17, 2006
1 parent c4d2444 commit a7d1f1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions net/sctp/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,16 @@ int sctp_rcv_ootb(struct sk_buff *skb)
sctp_errhdr_t *err;

ch = (sctp_chunkhdr_t *) skb->data;
ch_end = ((__u8 *) ch) + WORD_ROUND(ntohs(ch->length));

/* Scan through all the chunks in the packet. */
while (ch_end > (__u8 *)ch && ch_end < skb->tail) {
do {
/* Break out if chunk length is less then minimal. */
if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t))
break;

ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));
if (ch_end > skb->tail)
break;

/* RFC 8.4, 2) If the OOTB packet contains an ABORT chunk, the
* receiver MUST silently discard the OOTB packet and take no
Expand Down Expand Up @@ -622,8 +628,7 @@ int sctp_rcv_ootb(struct sk_buff *skb)
}

ch = (sctp_chunkhdr_t *) ch_end;
ch_end = ((__u8 *) ch) + WORD_ROUND(ntohs(ch->length));
}
} while (ch_end < skb->tail);

return 0;

Expand Down
2 changes: 2 additions & 0 deletions net/sctp/sm_statefuns.c
Original file line number Diff line number Diff line change
Expand Up @@ -3090,6 +3090,8 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
break;

ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));
if (ch_end > skb->tail)
break;

if (SCTP_CID_SHUTDOWN_ACK == ch->type)
ootb_shut_ack = 1;
Expand Down

0 comments on commit a7d1f1b

Please sign in to comment.