]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memory corruption in X.25 facilities parsing
authorandrew hendry <andrew.hendry@gmail.com>
Wed, 3 Nov 2010 12:54:53 +0000 (12:54 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Mar 2011 19:44:16 +0000 (12:44 -0700)
commit a6331d6f9a4298173b413cf99a40cc86a9d92c37 upstream.

Signed-of-by: Andrew Hendry <andrew.hendry@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/x25/x25_facilities.c
net/x25/x25_in.c

index a2765c6b1f1ac8082ba6a28908c4d94167d062a9..79cf932ddddefc6aaa7b6bea5e4d424b5f7441ee 100644 (file)
@@ -134,15 +134,15 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
                case X25_FAC_CLASS_D:
                        switch (*p) {
                        case X25_FAC_CALLING_AE:
-                               if (p[1] > X25_MAX_DTE_FACIL_LEN)
-                                       break;
+                               if (p[1] > X25_MAX_DTE_FACIL_LEN || p[1] <= 1)
+                                       return 0;
                                dte_facs->calling_len = p[2];
                                memcpy(dte_facs->calling_ae, &p[3], p[1] - 1);
                                *vc_fac_mask |= X25_MASK_CALLING_AE;
                                break;
                        case X25_FAC_CALLED_AE:
-                               if (p[1] > X25_MAX_DTE_FACIL_LEN)
-                                       break;
+                               if (p[1] > X25_MAX_DTE_FACIL_LEN || p[1] <= 1)
+                                       return 0;
                                dte_facs->called_len = p[2];
                                memcpy(dte_facs->called_ae, &p[3], p[1] - 1);
                                *vc_fac_mask |= X25_MASK_CALLED_AE;
index b39072f3a297f16137c0c274b13ff4ba2c964239..87739f27c96a686d296172a57f42c8f66cfdb106 100644 (file)
@@ -118,6 +118,8 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp
                                                &x25->vc_facil_mask);
                        if (len > 0)
                                skb_pull(skb, len);
+                       else
+                               return -1;
                        /*
                         *      Copy any Call User Data.
                         */