netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 2/2] tipc: potential divide by zero in tipc_link_recv_fragment()
@ 2013-05-06 18:29 Dan Carpenter
  2013-05-06 18:38 ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2013-05-06 18:29 UTC (permalink / raw)
  To: Jon Maloy
  Cc: Allan Stephens, David S. Miller, netdev, tipc-discussion,
	kernel-janitors

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>

diff --git a/net/tipc/link.c b/net/tipc/link.c
index 3a6064b3..de94493 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,
 		struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
 		u32 msg_sz = msg_size(imsg);
 		u32 fragm_sz = msg_data_sz(fragm);
-		u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
+		u32 exp_fragm_cnt;
 		u32 max =  TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
+
 		if (msg_type(imsg) == TIPC_MCAST_MSG)
 			max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
-		if (msg_size(imsg) > max) {
+		if (fragm_sz == 0 || msg_size(imsg) > max) {
 			kfree_skb(fbuf);
 			return 0;
 		}
+		exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
 		pbuf = tipc_buf_acquire(msg_size(imsg));
 		if (pbuf != NULL) {
 			pbuf->next = *pending;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-06 20:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-06 18:29 [patch 2/2] tipc: potential divide by zero in tipc_link_recv_fragment() Dan Carpenter
2013-05-06 18:38 ` Sergei Shtylyov
2013-05-06 18:49   ` Dan Carpenter
2013-05-06 19:31   ` [patch 2/2 v2] " Dan Carpenter
2013-05-06 20:17     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).