cupsd crashes in _ppdCreateFromIPP2() when a printer reports a media size with no PPD name (e.g. jpn_chou2)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Tất cả tám chỗ dùng NULL đều nằm trong _ppdCreateFromIPP2() trong cups/ppd-cache.c: hai giá trị mặc định ppdname và các lời gọi copy/snprintf("%s.Borderless") trong các vòng lặp media-col-database, media-size-supported và media-supported; phần ghi *PageSize ở bên dưới đã bảo vệ bằng && pwg->ppd, nên hãy dùng nó làm mẫu. pwg_ppdize_name() và mục gây lỗi _PWG_MEDIA_MM("jpn_chou2_111.1x146mm", NULL, NULL, ...) nằm trong cups/pwg-media.c. Tái hiện ngoài thiết bị bằng cách đưa attr.txt đính kèm qua ippReadIO() và _ppdCreateFromIPP(); hoàn tất nghĩa là không có segfault và PPD liệt kê đủ 20 kích thước, bao gồm Jpn_chou2_111.1x146mm.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Disclaimer:
Found with Claude while debugging my printing software; I reproduced it and checked the analysis myself. Explanation below was written by Claude, too.
Describe the bug
cupsd segfaults while creating a temporary queue for a DNS-SD discovered driverless printer when one of the printer's media sizes maps to a pwg_media_t entry that has no PPD name. _ppdCreateFromIPP2() (cups/ppd-cache.c) copies pwg->ppd with strlcpy() / snprintf("%s") (cupsCopyString() on master) without checking it for NULL.
In our case the printer reports a 111×146 mm size (custom_111x146mm_111x146mm in media-supported, x-dimension 11100 / y-dimension 14600 in media-col-database and media-size-supported). pwgMediaForSize() matches that, within its tolerance, to jpn_chou2_111.1x146mm, which is defined in cups/pwg-media.c without a PPD name: _PWG_MEDIA_MM("jpn_chou2_111.1x146mm", NULL, NULL, 111.1, 146).
There are eight such uses in _ppdCreateFromIPP2(): the two ppdname defaults (media-col-default / media-default) and the copy / snprintf("%s.Borderless") in the media-col-database, media-size-supported and media-supported loops. The *PageSize writer further down in the same file already checks && pwg->ppd, so elsewhere the code already treats this field as possibly NULL.
The same code is still there in 2.4.20, on the current 2.4.x branch and on master.
To Reproduce
- On a Mac, share an HP Deskjet F2400 (USB) over the network. The shared queue reports the 111×146 mm size described above (full attributes attached as
attr.txt). - On a Linux machine in the same network running cupsd with Avahi, the printer shows up as a temporary queue in
lpstat -l -e(network). - Run
lpoptions -p HP_Deskjet_F2400_series_Mac -l(or anything that callscupsCopyDestInfo()on it). That sends CUPS-Create-Local-Printer, and cupsd builds a PPD from the printer's attributes. - cupsd crashes with SIGSEGV. It is restarted, and the next query crashes it again.
Backtrace from the cupsd core dump (2.4.15, aarch64, cupsd without symbols):
#0 ?? () from libc.so.6
#1 strlcpy () from libc.so.6
#2 _ppdCreateFromIPP2 () from libcups.so.2
#3 ?? () (cupsd)
Same crash in an off-device repro: read the printer's Get-Printer-Attributes response with ippReadIO() and pass it to _ppdCreateFromIPP(). Against a 2.4.15 libcups with debug info:
#1 _cups_strlcpy (dst=..., src=0x0, size=...)
#3 _ppdCreateFromIPP2 (...) at ppd-cache.c:3721
Line 3721 is the strlcpy(temp.media, pwg->ppd, ...) in the media-col-database loop. The repro crashes on 2.4.15 and 2.4.20.
Expected behavior
cupsd creates the temporary queue. Sizes whose PWG entry has no PPD name get one made from the PWG name, or are skipped, instead of crashing.
A fix that works for us: fall back to a name built from the PWG name.
static const char *
pwg_ppd_name(pwg_media_t *pwg, char *buf, size_t bufsize)
{
if (pwg->ppd)
return (pwg->ppd);
pwg_ppdize_name(pwg->pwg, buf, bufsize);
return (buf);
}
Use pwg_ppd_name(pwg, ppdtemp, sizeof(ppdtemp)) in place of pwg->ppd at the eight places (ppdtemp being a local char[PPD_MAX_NAME]). With that, the PPD generated for the Deskjet has all 20 sizes including Jpn_chou2_111.1x146mm, and cupsd no longer crashes. A patch against 2.4.15 is available if useful.
System Information:
- OS and its version: custom Yocto Linux (yocto-5.3.4 / whinlatter), Raspberry Pi 5, aarch64, glibc 2.42, systemd
- Application:
lpoptions(CUPS CLI); also our own client callingcupsCopyDestInfo() - CUPS version: 2.4.15 (crash also reproduced with 2.4.20)
- Printer: HP Deskjet F2400, USB on a Mac and shared over the network (driverless temporary queue on the Linux side)
- Built with the OpenEmbedded recipe, configure options:
--enable-dbus --with-dbusdir=/etc/dbus-1 --enable-browsing --disable-gssapi --enable-debug --disable-relro --enable-libusb --with-system-groups=lpadmin,root,sys,wheel --with-cups-group=lp --with-domainsocket=/run/cups/cups.sock --with-dnssd=avahi --with-systemd=/usr/lib/systemd/system --with-tls=openssl
Additional context
- Attached: attr.txt, the
ipptool --ippserveroutput for the shared queue (see REPORTING_ISSUES.md). Hostname, location, UUID and the printer's serial number are replaced; all media attributes are unchanged. - I searched existing issues and PRs and didn't find this reported. #760 is related (PPD generation failing for a temporary queue) but is a different problem.
- Ngôn ngữ chính
- C
- Star
- 1.8k
- Fork
- 362
- Merge trung bình
- 19 giờ 12 phút
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenPrinting/cups
-
NULL pointer dereference in `print_job()` during MIME auto-detectionCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OpenPrinting/cups#1826 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OAuth (bearer) quota check denies every user when the allowed-user list is emptyCó thể đã có người làm @RonitMehta08 đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
OpenPrinting/cups#1795 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
cupsdGetPrivateAttrs: @ACL never grants access, and @OWNER is looked up as an operating-system group for non-ownersCó thể đã có người làm @user-Param đã nhận 10 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
OpenPrinting/cups#1796 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OAuth/OIDC token-validation gaps: nonce not enforced when absent, at_hash alg, inbound bearer not signature/aud/exp-validated + unverified email used for authzCó thể làm lại được @michaelrsweet đã nhận 148 ngày trước và không có pull request nào đang mở. Đang mởinvestigating
OpenPrinting/cups#1609 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
OpenPrinting/cups#1572 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenPrinting/cups
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
ESPresense/ESPresense#2680 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
ImageMagick/ImageMagick#9134 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Builder: a structure opened without calculation data shows the Diffraction (fibre) view by defaultĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
FriendsofECCE/ECCE#1245 · 1 bình luận ·
-
Arch: ARM/AArch64 Doc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
RT-Thread/rt-thread#12082 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/nuttx-apps#4108 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày