diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:45:10 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:45:10 -0400 |
commit | 08ffce4560e0133e10634b0dd85eecee11257a1c (patch) | |
tree | eff2a0266e0897e72e48db949fb28f367812222e /drivers/input | |
parent | 4854c7b27f0975a2b629f35ea3996d2968eb7c4f (diff) |
Input: fix potential overflows in driver/input/mouse
Change all sprintfs into snprintfs to make sure we won't stomp on
data adjacent to our buffers.
Noticed by Wouter Paesen <wouter@kangaroot.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/mouse/alps.c | 2 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse-base.c | 6 | ||||
-rw-r--r-- | drivers/input/mouse/sermouse.c | 2 | ||||
-rw-r--r-- | drivers/input/mouse/vsxxxaa.c | 22 |
4 files changed, 18 insertions, 14 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index a0e2e797c6d5..070d75330afd 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -470,7 +470,7 @@ int alps_init(struct psmouse *psmouse) | |||
470 | dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); | 470 | dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); |
471 | } | 471 | } |
472 | 472 | ||
473 | sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys); | 473 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys); |
474 | dev2->phys = priv->phys; | 474 | dev2->phys = priv->phys; |
475 | dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; | 475 | dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; |
476 | dev2->id.bustype = BUS_I8042; | 476 | dev2->id.bustype = BUS_I8042; |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 136321a2cfdb..5f21532c24ff 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -1057,8 +1057,8 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto | |||
1057 | if (psmouse->resync_time && psmouse->poll(psmouse)) | 1057 | if (psmouse->resync_time && psmouse->poll(psmouse)) |
1058 | psmouse->resync_time = 0; | 1058 | psmouse->resync_time = 0; |
1059 | 1059 | ||
1060 | sprintf(psmouse->devname, "%s %s %s", | 1060 | snprintf(psmouse->devname, sizeof(psmouse->devname), "%s %s %s", |
1061 | psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); | 1061 | psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); |
1062 | 1062 | ||
1063 | input_dev->name = psmouse->devname; | 1063 | input_dev->name = psmouse->devname; |
1064 | input_dev->phys = psmouse->phys; | 1064 | input_dev->phys = psmouse->phys; |
@@ -1099,7 +1099,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
1099 | ps2_init(&psmouse->ps2dev, serio); | 1099 | ps2_init(&psmouse->ps2dev, serio); |
1100 | INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); | 1100 | INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); |
1101 | psmouse->dev = input_dev; | 1101 | psmouse->dev = input_dev; |
1102 | sprintf(psmouse->phys, "%s/input0", serio->phys); | 1102 | snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); |
1103 | 1103 | ||
1104 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | 1104 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); |
1105 | 1105 | ||
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c index 2f9a04ae725f..a89742431717 100644 --- a/drivers/input/mouse/sermouse.c +++ b/drivers/input/mouse/sermouse.c | |||
@@ -254,7 +254,7 @@ static int sermouse_connect(struct serio *serio, struct serio_driver *drv) | |||
254 | goto fail; | 254 | goto fail; |
255 | 255 | ||
256 | sermouse->dev = input_dev; | 256 | sermouse->dev = input_dev; |
257 | sprintf(sermouse->phys, "%s/input0", serio->phys); | 257 | snprintf(sermouse->phys, sizeof(sermouse->phys), "%s/input0", serio->phys); |
258 | sermouse->type = serio->id.proto; | 258 | sermouse->type = serio->id.proto; |
259 | 259 | ||
260 | input_dev->name = sermouse_protocols[sermouse->type]; | 260 | input_dev->name = sermouse_protocols[sermouse->type]; |
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index 36e9442a16b2..7b85bc21ae4a 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c | |||
@@ -153,22 +153,25 @@ vsxxxaa_detection_done (struct vsxxxaa *mouse) | |||
153 | { | 153 | { |
154 | switch (mouse->type) { | 154 | switch (mouse->type) { |
155 | case 0x02: | 155 | case 0x02: |
156 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse"); | 156 | strlcpy (mouse->name, "DEC VSXXX-AA/-GA mouse", |
157 | sizeof (mouse->name)); | ||
157 | break; | 158 | break; |
158 | 159 | ||
159 | case 0x04: | 160 | case 0x04: |
160 | sprintf (mouse->name, "DEC VSXXX-AB digitizer"); | 161 | strlcpy (mouse->name, "DEC VSXXX-AB digitizer", |
162 | sizeof (mouse->name)); | ||
161 | break; | 163 | break; |
162 | 164 | ||
163 | default: | 165 | default: |
164 | sprintf (mouse->name, "unknown DEC pointer device " | 166 | snprintf (mouse->name, sizeof (mouse->name), |
165 | "(type = 0x%02x)", mouse->type); | 167 | "unknown DEC pointer device (type = 0x%02x)", |
168 | mouse->type); | ||
166 | break; | 169 | break; |
167 | } | 170 | } |
168 | 171 | ||
169 | printk (KERN_INFO "Found %s version 0x%02x from country 0x%02x " | 172 | printk (KERN_INFO |
170 | "on port %s\n", mouse->name, mouse->version, | 173 | "Found %s version 0x%02x from country 0x%02x on port %s\n", |
171 | mouse->country, mouse->phys); | 174 | mouse->name, mouse->version, mouse->country, mouse->phys); |
172 | } | 175 | } |
173 | 176 | ||
174 | /* | 177 | /* |
@@ -503,8 +506,9 @@ vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) | |||
503 | 506 | ||
504 | mouse->dev = input_dev; | 507 | mouse->dev = input_dev; |
505 | mouse->serio = serio; | 508 | mouse->serio = serio; |
506 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); | 509 | strlcat (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer", |
507 | sprintf (mouse->phys, "%s/input0", serio->phys); | 510 | sizeof (mouse->name)); |
511 | snprintf (mouse->phys, sizeof (mouse->phys), "%s/input0", serio->phys); | ||
508 | 512 | ||
509 | input_dev->name = mouse->name; | 513 | input_dev->name = mouse->name; |
510 | input_dev->phys = mouse->phys; | 514 | input_dev->phys = mouse->phys; |