diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2013-05-06 05:31:17 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-05-06 16:16:52 -0400 |
commit | 6bf15191f666c5965d212561d7a5c7b78b808dfa (patch) | |
tree | f8181fc3a6d91819c5da72989b185e4a7f78905f /net/tipc | |
parent | cb4b102f0ab29fcbaf945c6b1f85ef006cdb8edc (diff) |
tipc: potential divide by zero in tipc_link_recv_fragment()
The worry here is that fragm_sz could be zero since it comes from
skb->data.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/link.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index 3a6064b3d666..a80feee5197a 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -2524,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
2524 | struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm); | 2524 | struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm); |
2525 | u32 msg_sz = msg_size(imsg); | 2525 | u32 msg_sz = msg_size(imsg); |
2526 | u32 fragm_sz = msg_data_sz(fragm); | 2526 | u32 fragm_sz = msg_data_sz(fragm); |
2527 | u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz); | 2527 | u32 exp_fragm_cnt; |
2528 | u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE; | 2528 | u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE; |
2529 | |||
2529 | if (msg_type(imsg) == TIPC_MCAST_MSG) | 2530 | if (msg_type(imsg) == TIPC_MCAST_MSG) |
2530 | max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE; | 2531 | max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE; |
2531 | if (msg_size(imsg) > max) { | 2532 | if (fragm_sz == 0 || msg_size(imsg) > max) { |
2532 | kfree_skb(fbuf); | 2533 | kfree_skb(fbuf); |
2533 | return 0; | 2534 | return 0; |
2534 | } | 2535 | } |
2536 | exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz); | ||
2535 | pbuf = tipc_buf_acquire(msg_size(imsg)); | 2537 | pbuf = tipc_buf_acquire(msg_size(imsg)); |
2536 | if (pbuf != NULL) { | 2538 | if (pbuf != NULL) { |
2537 | pbuf->next = *pending; | 2539 | pbuf->next = *pending; |