aboutsummaryrefslogtreecommitdiffstats
path: root/cursor/wayland-cursor.c
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2021-05-14 13:06:15 +0200
committerSimon Ser <contact@emersion.fr>2021-06-02 13:46:33 +0000
commitabcf1048e23525865c2ff43ce90bbdaa80524246 (patch)
tree875debd79856094527361164481e7abfd2961655 /cursor/wayland-cursor.c
parentprotocol: drop reference to wl_drm (diff)
downloadwayland-abcf1048e23525865c2ff43ce90bbdaa80524246.tar
wayland-abcf1048e23525865c2ff43ce90bbdaa80524246.tar.gz
wayland-abcf1048e23525865c2ff43ce90bbdaa80524246.tar.bz2
wayland-abcf1048e23525865c2ff43ce90bbdaa80524246.tar.lz
wayland-abcf1048e23525865c2ff43ce90bbdaa80524246.tar.xz
wayland-abcf1048e23525865c2ff43ce90bbdaa80524246.tar.zst
wayland-abcf1048e23525865c2ff43ce90bbdaa80524246.zip
cursor: fix crash with weird input files
If a cursor file contains multiple images for the same size, this typically indicates an animation. The compositor weston uses wl_cursor_frame_and_duration to figure out at which time a specific image should be shown. The total delay is the sum of all image delays. But if all images have a delay of 0, the total delay is 0 as well. The code does not check for this special condition and triggers a floating point exception by eventually performing a modulo operation with 0. This, of course, could also happen if the sum of all image delays triggers an unsigned int overflow. But since a comment in the code already indicates that it does not try to "fix" handling of weird files, I would argue that it's "okay" if that happens. At least the program won't crash. Proof of Concept: install -D ~/.icons/poc/cursors base64 -d > ~/.icons/poc/cursors/left_ptr << EOF WGN1chAAAAAAAAEAAgAAAAIA/f8BAAAAKAAAAAIA/f8BAAAAKAAAACQAAAACAP3/AQAAAAEAAAAB AAAAAQAAAAEAAAABAAAAAAAAAAAAAAA= EOF cat > /tmp/weston.ini << EOF [shell] cursor-theme=poc EOF weston -c /tmp/weston.ini Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'cursor/wayland-cursor.c')
-rw-r--r--cursor/wayland-cursor.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index 4e2dc50..7da7014 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -475,7 +475,7 @@ wl_cursor_frame_and_duration(struct wl_cursor *_cursor, uint32_t time,
uint32_t t;
int i;
- if (cursor->cursor.image_count == 1) {
+ if (cursor->cursor.image_count == 1 || cursor->total_delay == 0) {
if (duration)
*duration = 0;
return 0;