]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Prevent missing direction arguments to segfault labwc
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 3 Jun 2022 00:19:31 +0000 (02:19 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 3 Jun 2022 18:07:13 +0000 (19:07 +0100)
Reported-by: @Flrian
src/action.c
src/view.c

index 646ca4d8cb74fdeb443524be0bf249fc18b5e02d..07539ecb2b495696c4098cca80ff8f9a4b04d425 100644 (file)
@@ -174,10 +174,18 @@ actions_run(struct view *activator, struct server *server,
                        wl_display_terminate(server->wl_display);
                        break;
                case ACTION_TYPE_MOVE_TO_EDGE:
-                       view_move_to_edge(view, action->arg);
+                       if (action->arg) {
+                               view_move_to_edge(view, action->arg);
+                       } else {
+                               wlr_log(WLR_ERROR, "Missing argument for MoveToEdge");
+                       }
                        break;
                case ACTION_TYPE_SNAP_TO_EDGE:
-                       view_snap_to_edge(view, action->arg);
+                       if (action->arg) {
+                               view_snap_to_edge(view, action->arg);
+                       } else {
+                               wlr_log(WLR_ERROR, "Missing argument for SnapToEdge");
+                       }
                        break;
                case ACTION_TYPE_NEXT_WINDOW:
                        server->cycle_view = desktop_cycle_view(server,
index 443b6e643815035e1678a396ce2f9cbe3214f3b8..b852425355794f8308e39cb5d360e140eb6d2c3c 100644 (file)
@@ -460,6 +460,10 @@ view_move_to_edge(struct view *view, const char *direction)
                wlr_log(WLR_ERROR, "no output");
                return;
        }
+       if (!direction) {
+               wlr_log(WLR_ERROR, "invalid edge");
+               return;
+       }
        struct wlr_box usable = output_usable_area_in_layout_coords(output);
        if (usable.height == output->wlr_output->height
                        && output->wlr_output->scale != 1) {
@@ -485,6 +489,9 @@ view_move_to_edge(struct view *view, const char *direction)
                x = view->x;
                y = usable.y + usable.height - view->h - view->margin.bottom
                        - rc.gap;
+       } else {
+               wlr_log(WLR_ERROR, "invalid edge");
+               return;
        }
        view_move(view, x, y);
 }
@@ -521,6 +528,9 @@ view_edge_invert(enum view_edge edge)
 static enum view_edge
 view_edge_parse(const char *direction)
 {
+       if (!direction) {
+               return VIEW_EDGE_INVALID;
+       }
        if (!strcasecmp(direction, "left")) {
                return VIEW_EDGE_LEFT;
        } else if (!strcasecmp(direction, "up")) {