New: ethernet/dec/tulip/tulip_core.c:592: array index check in wrong place ?
Subsystems (2)
Begin forwarded message:
Date: Thu, 10 Jul 2014 04:21:24 -0700
From: "[email protected]" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Bug 79811] New: ethernet/dec/tulip/tulip_core.c:592: array index check in wrong place ?
https://bugzilla.kernel.org/show_bug.cgi?id=79811
Bug ID: 79811
Summary: ethernet/dec/tulip/tulip_core.c:592: array index check
in wrong place ?
Product: Networking
Version: 2.5
Kernel Version: 3.16-rc4
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: Other
Assignee: [email protected]
Reporter: [email protected]
Regression: Noethernet/dec/tulip/tulip_core.c:592]: (style) Array index 'j' is used before limits check.
for (j = 0; buf[j] != 0xee && j < 1600; j++)
Suggest put limit check before index use.
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
David Miller
maintainerFrom: Stephen Hemminger <[email protected]>
Date: Thu, 10 Jul 2014 05:50:22 -0700
Quoted 1 line
Subject: [Bug 79811] New:
ethernet/dec/tulip/tulip_core.c:592: array index check in wrong place ?
...
Quoted 6 lines
ethernet/dec/tulip/tulip_core.c:592]: (style) Array index 'j' is used before limits check.for (j = 0; buf[j] != 0xee && j < 1600; j++)Suggest put limit check before index use.
This code has never actually ever been compiled for at least a decade or two, it's ifdef protected against "way_too_many_messages" which nothing will ever define.
This is what really eats me about automated tools sometimes, and in this case I have two gripes:
1) The tool doesn't take into consideration that the code might never be compiled.
2) The code actually is buggy is far more important ways, it takes a DMA mapping cookie and dereferences it as a CPU pointer:
u8 *buf = (u8 *)(tp->rx_ring[i].buffer1);
which is guaranteed to not work.
So in actuality this entire code block should be rewritten or removed.