public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/char/tipar.c: off by one array access
@ 2005-06-19 15:15 Luc Van Oostenryck
  2005-06-20  3:03 ` randy_dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Luc Van Oostenryck @ 2005-06-19 15:15 UTC (permalink / raw)
  To: linux-kernel, roms

In the setupt function, the delay variable is initialized with ints[2],
but ints is declared as:
	int ints[2];

Since the module parameter should correspond to:
	tipar=timeout,delay

I suppose that the following patch fix the problem.


Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net>

diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -407,7 +407,7 @@ tipar_setup(char *str)
                          printk(KERN_WARNING "tipar: bad timeout value (0), "
  				"using default value instead");
  		if (ints[0] > 1) {
-			delay = ints[2];
+			delay = ints[1];
  		}
  	}




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

* Re: [PATCH] drivers/char/tipar.c: off by one array access
  2005-06-19 15:15 [PATCH] drivers/char/tipar.c: off by one array access Luc Van Oostenryck
@ 2005-06-20  3:03 ` randy_dunlap
  2005-06-20 22:35   ` Luc Van Oostenryck
  0 siblings, 1 reply; 3+ messages in thread
From: randy_dunlap @ 2005-06-20  3:03 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-kernel, roms

On Sun, 19 Jun 2005 17:15:30 +0200 Luc Van Oostenryck wrote:

| In the setupt function, the delay variable is initialized with ints[2],
| but ints is declared as:
| 	int ints[2];
| 
| Since the module parameter should correspond to:
| 	tipar=timeout,delay
| 
| I suppose that the following patch fix the problem.
| 
| 
| Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net>
| 
| diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
| --- a/drivers/char/tipar.c
| +++ b/drivers/char/tipar.c
| @@ -407,7 +407,7 @@ tipar_setup(char *str)
|                           printk(KERN_WARNING "tipar: bad timeout value (0), "
|   				"using default value instead");
|   		if (ints[0] > 1) {
| -			delay = ints[2];
| +			delay = ints[1];
|   		}
|   	}

That (re)uses the timeout value for delay.
Please try again....

get_options() sets ints[0] to the number of parameters parsed
and tipar_setup() clearly wants to parse as you described:
| 	tipar=timeout,delay
so the ints[] array needs to be [3], not [2].

---
~Randy

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

* Re: [PATCH] drivers/char/tipar.c: off by one array access
  2005-06-20  3:03 ` randy_dunlap
@ 2005-06-20 22:35   ` Luc Van Oostenryck
  0 siblings, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2005-06-20 22:35 UTC (permalink / raw)
  To: randy_dunlap; +Cc: linux-kernel, roms

randy_dunlap wrote:
> On Sun, 19 Jun 2005 17:15:30 +0200 Luc Van Oostenryck wrote:
> 
> | In the setupt function, the delay variable is initialized with ints[2],
> | but ints is declared as:
> | 	int ints[2];
> | 
> | Since the module parameter should correspond to:
> | 	tipar=timeout,delay
> | 
> | I suppose that the following patch fix the problem.

...

> 
> That (re)uses the timeout value for delay.
> Please try again....
> 
> get_options() sets ints[0] to the number of parameters parsed
> and tipar_setup() clearly wants to parse as you described:
> | 	tipar=timeout,delay
> so the ints[] array needs to be [3], not [2].
> 
> ---
> ~Randy

Yes, sorry. Here is another patch.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net>

diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -396,7 +396,7 @@ static struct file_operations tipar_fops
  static int __init
  tipar_setup(char *str)
  {
-	int ints[2];
+	int ints[3];

  	str = get_options(str, ARRAY_SIZE(ints), ints);



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

end of thread, other threads:[~2005-06-21  4:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-19 15:15 [PATCH] drivers/char/tipar.c: off by one array access Luc Van Oostenryck
2005-06-20  3:03 ` randy_dunlap
2005-06-20 22:35   ` Luc Van Oostenryck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox