diff options
author | Tilman Schmidt <tilman@imap.cc> | 2014-10-11 07:46:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-14 15:05:35 -0400 |
commit | 2bf3a09ea51f807d78d48d0ebc591b9e1502a743 (patch) | |
tree | 40c6cdd92de50e053f80d83617ae119d1f7d9338 /drivers/isdn/capi | |
parent | 5510ab18048397193ae073d6b0d4ea78ff0170f5 (diff) |
isdn/capi: handle CAPI 2.0 message parser failures
Have callers of capi_cmsg2message and capi_message2cmsg handle
non-zero return values indicating failure.
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/capi')
-rw-r--r-- | drivers/isdn/capi/capidrv.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index fd6d28f3fc36..1cc6ca8bfbda 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c | |||
@@ -506,7 +506,10 @@ static void send_message(capidrv_contr *card, _cmsg *cmsg) | |||
506 | struct sk_buff *skb; | 506 | struct sk_buff *skb; |
507 | size_t len; | 507 | size_t len; |
508 | 508 | ||
509 | capi_cmsg2message(cmsg, cmsg->buf); | 509 | if (capi_cmsg2message(cmsg, cmsg->buf)) { |
510 | printk(KERN_ERR "capidrv::send_message: parser failure\n"); | ||
511 | return; | ||
512 | } | ||
510 | len = CAPIMSG_LEN(cmsg->buf); | 513 | len = CAPIMSG_LEN(cmsg->buf); |
511 | skb = alloc_skb(len, GFP_ATOMIC); | 514 | skb = alloc_skb(len, GFP_ATOMIC); |
512 | if (!skb) { | 515 | if (!skb) { |
@@ -1578,7 +1581,12 @@ static _cmsg s_cmsg; | |||
1578 | 1581 | ||
1579 | static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb) | 1582 | static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb) |
1580 | { | 1583 | { |
1581 | capi_message2cmsg(&s_cmsg, skb->data); | 1584 | if (capi_message2cmsg(&s_cmsg, skb->data)) { |
1585 | printk(KERN_ERR "capidrv: applid=%d: received invalid message\n", | ||
1586 | ap->applid); | ||
1587 | kfree_skb(skb); | ||
1588 | return; | ||
1589 | } | ||
1582 | if (debugmode > 3) { | 1590 | if (debugmode > 3) { |
1583 | _cdebbuf *cdb = capi_cmsg2str(&s_cmsg); | 1591 | _cdebbuf *cdb = capi_cmsg2str(&s_cmsg); |
1584 | 1592 | ||
@@ -1903,7 +1911,11 @@ static int capidrv_command(isdn_ctrl *c, capidrv_contr *card) | |||
1903 | NULL, /* Useruserdata */ | 1911 | NULL, /* Useruserdata */ |
1904 | NULL /* Facilitydataarray */ | 1912 | NULL /* Facilitydataarray */ |
1905 | ); | 1913 | ); |
1906 | capi_cmsg2message(&cmdcmsg, cmdcmsg.buf); | 1914 | if (capi_cmsg2message(&cmdcmsg, cmdcmsg.buf)) { |
1915 | printk(KERN_ERR "capidrv-%d: capidrv_command: parser failure\n", | ||
1916 | card->contrnr); | ||
1917 | return -EINVAL; | ||
1918 | } | ||
1907 | plci_change_state(card, bchan->plcip, EV_PLCI_CONNECT_RESP); | 1919 | plci_change_state(card, bchan->plcip, EV_PLCI_CONNECT_RESP); |
1908 | send_message(card, &cmdcmsg); | 1920 | send_message(card, &cmdcmsg); |
1909 | return 0; | 1921 | return 0; |
@@ -2090,7 +2102,11 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) | |||
2090 | if (capidrv_add_ack(nccip, datahandle, doack ? (int)skb->len : -1) < 0) | 2102 | if (capidrv_add_ack(nccip, datahandle, doack ? (int)skb->len : -1) < 0) |
2091 | return 0; | 2103 | return 0; |
2092 | 2104 | ||
2093 | capi_cmsg2message(&sendcmsg, sendcmsg.buf); | 2105 | if (capi_cmsg2message(&sendcmsg, sendcmsg.buf)) { |
2106 | printk(KERN_ERR "capidrv-%d: if_sendbuf: parser failure\n", | ||
2107 | card->contrnr); | ||
2108 | return -EINVAL; | ||
2109 | } | ||
2094 | msglen = CAPIMSG_LEN(sendcmsg.buf); | 2110 | msglen = CAPIMSG_LEN(sendcmsg.buf); |
2095 | if (skb_headroom(skb) < msglen) { | 2111 | if (skb_headroom(skb) < msglen) { |
2096 | struct sk_buff *nskb = skb_realloc_headroom(skb, msglen); | 2112 | struct sk_buff *nskb = skb_realloc_headroom(skb, msglen); |