Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#46 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenPrinting/fuzzing のほかの issue

OpenPrinting/fuzzing の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。