diff options
author | Simon Ser <contact@emersion.fr> | 2022-12-13 18:27:58 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-12-13 19:44:44 +0000 |
commit | c675380c56437a522c54e179131d42cb96f6e6cf (patch) | |
tree | 8fd183e35015f3ee8f95464e29ce9dc79764c78e /backend | |
parent | bde68b1df79cef058a75d28c52a1544044bf3f70 (diff) |
backend/drm: prevent out-of-bounds array access on unknown subpixel
If the kernel adds new enum entries for subpixel, don't read past
the end of the subpixel_map array.
Diffstat (limited to 'backend')
-rw-r--r-- | backend/drm/drm.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 380e5629..94bf2059 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1245,7 +1245,11 @@ static void connect_drm_connector(struct wlr_drm_connector *wlr_conn, wlr_conn->output.phys_height = drm_conn->mmHeight; wlr_log(WLR_INFO, "Physical size: %"PRId32"x%"PRId32, wlr_conn->output.phys_width, wlr_conn->output.phys_height); - wlr_conn->output.subpixel = subpixel_map[drm_conn->subpixel]; + if (drm_conn->subpixel < sizeof(subpixel_map) / sizeof(subpixel_map[0])) { + wlr_conn->output.subpixel = subpixel_map[drm_conn->subpixel]; + } else { + wlr_log(WLR_ERROR, "Unknown subpixel value: %d", (int)drm_conn->subpixel); + } get_drm_connector_props(drm->fd, wlr_conn->id, &wlr_conn->props); |