]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SCTP]: Fix sctp_rcv_ootb() to handle the last chunk of a packet correctly.
authorTsutomu Fujii <t-fujii@nb.jp.nec.com>
Tue, 17 Jan 2006 19:57:09 +0000 (11:57 -0800)
committerSridhar Samudrala <sri@us.ibm.com>
Tue, 17 Jan 2006 19:57:09 +0000 (11:57 -0800)
Signed-off-by: Tsutomu Fujii <t-fujii@nb.jp.nec.com>
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
net/sctp/input.c
net/sctp/sm_statefuns.c

index 71fd563756414d43db5b3a7b176326fc59d3d75d..cb78b50868eee0c765884565dbdc4b6d4c2df01b 100644 (file)
@@ -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
@@ -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;
 
index 477d7f80dba686713ac6b10288f343a581e1ba5b..71c9a961c321a13e6b68e837cc47652e27a4e437 100644 (file)
@@ -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;