mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-05 00:38:00 +02:00
xfree86: parser: Never use constant strings for driver names (fixes #17438)
When the parser sees the "keyboard" driver, it automatically (and
silently) replaces it with the constant string "kbd".
Everybody else uses malloc'd memory for the driver name, so input
device closure assumes it can use free.
Free val.str, so this crash doesn't turn into a memory leak. Whew.
Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit bce12f2956)
This commit is contained in:
parent
5e5cb1b19e
commit
929d43d3da
2 changed files with 9 additions and 4 deletions
|
|
@ -59,6 +59,7 @@
|
|||
#include <xorg-config.h>
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "xf86Parser.h"
|
||||
#include "xf86tokens.h"
|
||||
#include "Configint.h"
|
||||
|
|
@ -102,8 +103,10 @@ xf86parseInputSection (void)
|
|||
case DRIVER:
|
||||
if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
|
||||
Error (QUOTE_MSG, "Driver");
|
||||
if (strcmp(val.str, "keyboard") == 0)
|
||||
ptr->inp_driver = "kbd";
|
||||
if (strcmp(val.str, "keyboard") == 0) {
|
||||
ptr->inp_driver = strdup("kbd");
|
||||
free(val.str);
|
||||
}
|
||||
else
|
||||
ptr->inp_driver = val.str;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -85,8 +85,10 @@ xf86parseInputClassSection(void)
|
|||
case DRIVER:
|
||||
if (xf86getSubToken(&(ptr->comment)) != STRING)
|
||||
Error(QUOTE_MSG, "Driver");
|
||||
if (strcmp(val.str, "keyboard") == 0)
|
||||
ptr->driver = "kbd";
|
||||
if (strcmp(val.str, "keyboard") == 0) {
|
||||
ptr->driver = strdup("kbd");
|
||||
free(val.str);
|
||||
}
|
||||
else
|
||||
ptr->driver = val.str;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue