Skip to contentSkip to conversation

drivers/char/tipar.c: off by one array access

PATCH In review Luc Van Oostenryck 2 participants 3 messages Jun 19, 2005 – Jun 21, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/char/tipar.c: off by one array access

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.

drivers/char/tipar.c +1 -1
@@ -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];
 		}
 	}
 
#1 lore raw

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 <[email protected]>
| 
| 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

#2 lore raw
Quoted 8 lines · randy_dunlap

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.

...

Quoted 11 lines

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.

drivers/char/tipar.c +1 -1
@@ -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);