Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Memory leak in PPD parser when processing duplicate JCLBegin/JCLEnd keywords

未关闭
#46 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
c

调研方向

从 cups/ppd.c 的 _ppdOpen() 函数开始,检查 issue 中确定的 JCLBegin 和 JCLEnd 处理代码。使用包含重复关键字的 PPD 或 fuzzing testcase 重现问题,然后在 AddressSanitizer 和 LeakSanitizer 下运行 fuzz_ppd_gen_cache。重复关键字不再产生 leak 即表示完成。

由索引模型根据 Issue 内容生成。

描述

Summary

A memory leak vulnerability exists in the CUPS PPD parser (cups/ppd.c) when processing PPD files containing duplicate *JCLBegin or *JCLEnd keywords. Each duplicate keyword causes the previously allocated memory to be orphaned and permanently leaked.

Discovery Method

  • Fuzzer: fuzz_ppd_gen_cache
  • Detection: AddressSanitizer + LeakSanitizer
  • Date: 2025-11-10

Vulnerability Details

Location
  • File: cups/ppd.c
  • Lines: 851 (JCLBegin), 856 (JCLEnd)
  • Function: _ppdOpen()
Root Cause

The parser calls strdup() to allocate memory for JCL keywords without freeing any previously allocated value:

// Line 850-853
else if (!strcmp(keyword, "JCLBegin"))
{
    ppd->jcl_begin = strdup(string);  // ❌ No free() before assignment
    ppd_decode(ppd->jcl_begin);
}

If a PPD file contains multiple *JCLBegin lines:

  1. First occurrence: Allocates memory A, assigns to ppd->jcl_begin
  2. Second occurrence: Allocates memory B, overwrites ppd->jcl_begin
  3. Memory A is orphaned and leaked (cannot be freed)

The same issue exists for *JCLEnd at line 856.

LeakSanitizer Report

==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 9 byte(s) in 1 object(s) allocated from:
    #0 0x5558f3468afa in strdup /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:596:3
    #1 0x5558f35267d2 in _ppdOpen /src/cups/cups/ppd.c:851:24
    #2 0x5558f3530e76 in _ppdOpenFile /src/cups/cups/ppd.c:2283:11
    #3 0x5558f34c65f7 in LLVMFuzzerTestOneInput /src/cups/ossfuzz/fuzz_ppd_gen_cache.c:289:23

SUMMARY: AddressSanitizer: 9 byte(s) leaked in 1 allocation(s).

Reproduction

Test Case

Fuzzer-generated input: leak-e4ef53d9b1772ff55e830f4060f2afb3c6a79270 (313 bytes)

Analysis shows the file contains two *JCLBegin keywords:

$ strings fuzzer_testcase.bin | grep JCLBegin
*JCLBegin:
*JCLBegin:
Minimal Reproducer

Create a PPD file with duplicate *JCLBegin:

*PPD-Adobe: "4.3"
*FormatVersion: "4.3"
*FileVersion: "1.0"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*PCFileName: "LEAK.PPD"
*Manufacturer: "Test"
*Product: "(Test Printer)"
*ModelName: "Test Leak"
*ShortNickName: "Test"
*NickName: "Test Memory Leak"
*PSVersion: "(3010.000) 0"

*JCLBegin: "first_value"
*JCLBegin: "second_value"

*OpenUI *PageSize: PickOne
*DefaultPageSize: Letter
*PageSize Letter: ""
*CloseUI: *PageSize
主要语言
C
星标
8
派生
18
平均合并
7 小时 37 分钟
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenPrinting/fuzzing 的其他 Issue

查看 OpenPrinting/fuzzing 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。