swayfx/sway
Michael Weiser 730efbc89c Prevent use-after-free on first bar subcommand error
If any error is encountered during execution of the first subcommand of
a freshly created bar configuration, parsing apparently is to be aborted
and the current bar config is freed. The pointer to that memory is left
dangling though, leading to a use-after-free on successive bar
subcommands. This quite reliably ends in a crash like so:

sway -c reproducer.config
00:00:00.083 [sway/config.c:865] Error on line 2 'foo bar': Unknown/invalid command 'foo' (s)
free(): double free detected in tcache 2
00:00:00.608 [swaynag/swaynag.c:451] failed to register with the wayland display
Aborted (core dumped)

Minimal reproducer config:
bar {
        foo bar
        position top
}

Other messages:
malloc(): unaligned fastbin chunk detected
double free or corruption (fasttop)

The invalid command has to be the first for a newly created bar config.
Removing the command or switching order so it's not the first one masks
the problem.

Prevent this from occuring by resetting the pointer to NULL after
freeing the memory.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2021-04-18 20:53:36 -07:00
..
commands Prevent use-after-free on first bar subcommand error 2021-04-18 20:53:36 -07:00
config output: Reconfigure xcursor when applying output config 2021-02-24 20:54:48 +01:00
desktop desktop/layer_shell: fix centering for opposing anchors 2021-04-12 12:13:25 -07:00
input Implement input method keyboard grab 2021-03-12 12:18:08 +01:00
tree container: don't set fullscreen on children 2021-04-15 16:58:27 -07:00
commands.c Fix for_window criteria and mouse button bindings 2021-02-25 09:48:39 -05:00
config.c config: allow whitespaces in config path 2021-03-25 17:22:26 +01:00
criteria.c container: Move pending state to state struct 2021-02-16 22:05:00 -05:00
decoration.c Fix double free when unmapping any view 2018-11-15 15:22:09 +10:00
ipc-json.c container: Move pending state to state struct 2021-02-16 22:05:00 -05:00
ipc-server.c Fix incorrect format specifiers 2020-07-30 22:02:42 -04:00
main.c Log wlroots version on startup 2021-04-12 16:18:17 +02:00
meson.build Automatically map built-in touchscreens/tablets to built-in panels 2021-02-25 09:38:00 -05:00
server.c Remove WLR_HAS_XDG_FOREIGN checks 2021-04-11 19:14:05 +02:00
sway-bar.5.scd Add support for workspace_min_width bar option. 2020-10-11 19:12:42 +02:00
sway-input.5.scd man: document input XXX map_to_output * 2021-02-25 09:38:00 -05:00
sway-ipc.7.scd document parse_error 2020-11-21 11:42:29 +01:00
sway-output.5.scd Add toggle logic inside DPMS handler 2021-03-25 11:01:04 +01:00
sway.1.scd man: update maintainer 2021-01-08 09:33:51 +01:00
sway.5.scd Change workspace_layout to match i3 behavior 2020-12-20 00:58:42 -05:00
swaynag.c Rename symbol set_cloexec to sway_set_cloexec, remove duplicates. 2019-11-01 12:41:08 -04:00
xdg_decoration.c Fix xdg-decoration unconfigured if set before first commit 2019-05-03 15:37:32 -06:00