Skip to content

Commit

Permalink
[LAPB]: Fix windowsize check
Browse files Browse the repository at this point in the history
In bug #6954, Norbert Reinartz reported the following issue:

"Function lapb_setparms() in file net/lapb/lapb_iface.c checks if the given
parameters are valid. If the given window size is in the range of 8 .. 127,
lapb_setparms() fails and returns an error value of LAPB_INVALUE, even if bit
LAPB_EXTENDED in parms->mode is set.
If bit LAPB_EXTENDED in parms->mode is set and the window size is in the range
of 8 .. 127, the first check "(parms->mode & LAPB_EXTENDED)" results true  and
the second check "(parms->window < 1 || parms->window > 127)" results false.
Both checks in conjunction result to false, thus the third check "(parms->window
< 1 || parms->window > 7)" is done by fault.
This third check results true, so that we leave lapb_setparms() by 'goto out_put'.
Seems that this bug doesn't cause any problems, because lapb_setparms() isn't
used to change the default values of LAPB. We are using kernel lapb in our
software project and also change the default parameters of lapb, so we found
this bug"

He also pasted a fix, that I've transformated into a patch:

Signed-off-by: Diego Calleja <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
dcghub authored and davem330 committed Aug 6, 2006
1 parent d254bcd commit 558e10a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions net/lapb/lapb_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms)
goto out_put;

if (lapb->state == LAPB_STATE_0) {
if (((parms->mode & LAPB_EXTENDED) &&
(parms->window < 1 || parms->window > 127)) ||
(parms->window < 1 || parms->window > 7))
goto out_put;

if (parms->mode & LAPB_EXTENDED) {
if (parms->window < 1 || parms->window > 127)
goto out_put;
} else {
if (parms->window < 1 || parms->window > 7)
goto out_put;
}
lapb->mode = parms->mode;
lapb->window = parms->window;
}
Expand Down

0 comments on commit 558e10a

Please sign in to comment.