Subject: Re: [patch] netrom: check that user string is terminated

From: Ralf Baechle <[email-masked]>
Date: Wed, 23 Nov 2011 19:12:49 +0000

On Wed, Nov 23, 2011 at 09:22:16AM +0100, walter harms wrote:

> I am not sure that it does what you intends.
> mnemonic is an array and a  malicious use may fill it upto the last char
> causing strlen go beyond. perhaps this may help:

Correct, it makes thigs worse.  I'm going to reply in detail later tonight,
have to bail out now.

> >  		if ((dev = nr_ax25_dev_get(nr_route.device)) == NULL)
> >  			return -EINVAL;
> while you are here:
> 
> 	dev = nr_ax25_dev_get(nr_route.device);
> 	if ( dev == NULL )
> 		return -EINVAL;
> 
> >  		if (nr_route.ndigis < 0 || nr_route.ndigis > AX25_MAX_DIGIS) {
> 
> if guess "nr_route.ndigis >= AX25_MAX_DIGIS" is intended ?

No, values of 0 .. AX25_MAX_DIGIS are permitted with zero meaning no
digipeater at all.

The actual bug if you want to call it that in this line is cosmetic -
nr_route.ndigis is an unsigned int so nr_route.ndigis < 0 will never become
true.  There are other simplifications possible to the error checking
here.  I've whipped a cleanup patch for this part of the code.

  Ralf