]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config/rcxml.c: fix crash in <touch> section
authorJohan Malm <jgm323@gmail.com>
Sun, 8 Dec 2024 17:31:23 +0000 (17:31 +0000)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 8 Dec 2024 19:01:01 +0000 (20:01 +0100)
...when options are specified as elements leading to hitting the assert()
in xstrdup().

Reproduce by using this rc.xml:

```
<?xml version="1.0"?>
<labwc_config>
  <touch>
    <deviceName>foo</deviceName>
    <mapToOutput>bar</mapToOutput>
  </touch>
</labwc_config>
```

It is likely that <touch> was only tested with options as attributes.

src/config/rcxml.c

index eeb9d681de25ac8c630a0e7e4caebf9ad1e00d1d..cb064fc00f8c8e6344dd0e06f59fe7c61eb4d914 100644 (file)
@@ -646,7 +646,14 @@ fill_touch(char *nodename, char *content)
        if (!strcasecmp(nodename, "touch")) {
                current_touch = znew(*current_touch);
                wl_list_append(&rc.touch_configs, &current_touch->link);
-       } else if (!strcasecmp(nodename, "deviceName.touch")) {
+               return;
+       }
+
+       if (!content) {
+               return;
+       }
+
+       if (!strcasecmp(nodename, "deviceName.touch")) {
                xstrdup_replace(current_touch->device_name, content);
        } else if (!strcasecmp(nodename, "mapToOutput.touch")) {
                xstrdup_replace(current_touch->output_name, content);