[email protected]: empty pseudo class from format_timespan() causes heap over-read in St find_class_name() and crashes Cinnamon

Đang mở
#14,137 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 8 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
desktop

Hướng nghiên cứu

Start with files/usr/share/cinnamon/applets/[email protected]/eventView.js and trace how format_timespan()'s pseudo class reaches update_variations(). Then inspect src/st/st-widget.c, especially find_class_name(), and the attached reproduction details. Confirm the fix prevents the crash for events starting 60 minutes or more later today while preserving their countdown text.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

BUG
Distribution

NixOS 26.05

Package version

6.6.8

Graphics hardware in use

not relevant

Frequency

Only occasionally

Bug description

Cinnamon sometimes segfaults right after login, or when the calendar server updates events. Then the "fallback mode / restart Cinnamon?" dialog appears. It only happens when there are calendar events, and it happens at random.

01-bug-description.md

Steps to reproduce

In Cinnamon (random, depends on heap layout):

  1. Have a calendar with an event today that starts 60 minutes or more from now, so it shows in the calendar applet.
  2. Log in, or wait for the calendar server to send an event update.
  3. Sometimes Cinnamon segfaults with the stack trace above.

02-steps-to-reproduce.md

Expected behavior

Cinnamon does not crash. An event that starts later today shows its countdown text ("In 2 hours", "Starting later today", …) without adding a pseudo class.

Additional information
Cause
  1. format_timespan() in files/usr/share/cinnamon/applets/[email protected]/eventView.js returns "" as the pseudo class for events that start today 60 minutes or more from now (return ["", ...]).
  2. update_variations() passes it on unconditionally:
  3. countdown_label is the last child of label_box. st_widget_last_child_notify() has already given it the pseudo class last-child, so class_list is not empty.
  4. In src/st/st-widget.c, find_class_name() loops with strstr (match + 1, class_name). With class_name == "", strstr never returns NULL. For class_list = "last-child" no position meets the conditions, so the loop steps past the terminating NUL and keeps reading heap memory. It stops either when some bytes happen to match (no crash, but a bogus "found" result) or when it reaches an unmapped page (segfault). This is why the crash is random.

04-additional-information.md

Ngôn ngữ chính
JavaScript
Star
5.7k
Fork
941
Merge trung bình
6 ngày 18 giờ
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của linuxmint/cinnamon

Tất cả issue của linuxmint/cinnamon

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.