lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Oct 2007 01:05:39 +0200
From:	Roel Kluin <12o3l@...cali.nl>
To:	"Maciej W. Rozycki" <macro@...ux-mips.org>
CC:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tty_ioctl: Fix the baud_table check in encode_baud_rate

Since you were sending a fix, possibly I shouldn't comment on this. If so please disregard my
suggestion for a trivial cleanup.

Roel

Maciej W. Rozycki wrote:
> +void tty_termios_encode_baud_rate(struct ktermios *termios,
> +				  speed_t ibaud, speed_t obaud)
>  {
>  	int i = 0;
>  	int ifound = -1, ofound = -1;
> @@ -251,12 +252,15 @@ void tty_termios_encode_baud_rate(struct
>  	termios->c_cflag &= ~CBAUD;
>  
>  	do {
> -		if (obaud - oclose >= baud_table[i] && obaud + oclose <= baud_table[i]) {
> +		if (obaud - oclose <= baud_table[i] &&
> +		    obaud + oclose >= baud_table[i]) {

if(a - b <= c && a + b >= c)
if(a <= c + b && a + b >= c)
if(c + b >= a && a + b >= c)
if(b >= a - c && b >= c - a)
true, if:
b >= |a - c|
so
		if (oclose >= abs(obaud - baud_table[i])) {

should work as well

>  			termios->c_cflag |= baud_bits[i];
>  			ofound = i;
>  		}
> -		if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= baud_table[i]) {
> -			/* For the case input == output don't set IBAUD bits if the user didn't do so */
> +		if (ibaud - iclose <= baud_table[i] &&
> +		    ibaud + iclose >= baud_table[i]) {

similarly,
		if (iclose >= abs(ibaud - baud_table[i])) {

> +			/* For the case input == output don't set IBAUD bits
> +			   if the user didn't do so */
>  			if (ofound != i || ibinput)
>  				termios->c_cflag |= (baud_bits[i] << IBSHIFT);
>  			ifound = i;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ