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

MacFileUtils: FSPathMakeRef passes an int where the C function takes its FSRef output pointer

オープン 初心者向け
#1,746 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
79/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java の64~65行目付近にある FileManager の宣言を確認し、FSPathMakeRef を引用された CarbonCore の宣言および隣接する FSPathMakeRefWithOptions のシグネチャと比較してください。不足している FSRef 出力パラメーターを修正するか、非推奨の宣言を削除し、その後、宣言が C 関数のシグネチャと一致することを確認してください。issue によると、ビルドも実行も行われていません。

索引モデルが issue の本文から書いたものです。

説明

FileManager.FSPathMakeRef is declared with an int options as its second argument. The C function has no options parameter: its second argument is the FSRef * it writes the result to.

// contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java:64-65
int FSPathMakeRef(String source, int options, ByteByReference isDirectory);
int FSPathMakeRefWithOptions(String source, int options, FSRef fsref, ByteByReference isDirectory);
// CarbonCore/Files.h:4116 (macOS SDK 26.1)
extern OSStatus  FSPathMakeRef(const UInt8 *path, FSRef *ref, Boolean *isDirectory)        __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);

It looks like the parameter list of FSPathMakeRefWithOptions, one line below, with the FSRef dropped.

What it can cause

The callee writes its 80-byte FSRef to whatever address the options integer names: options = 0 hands it a NULL output pointer, and any other value is an arbitrary address. Either way the caller has no FSRef to read the result from. Nothing in JNA calls it, so only code that calls it directly is affected.

Fix

int FSPathMakeRef(String path, FSRef ref, ByteByReference isDirectory);, or drop it, since it has been deprecated since 10.8 and FSPathMakeRefWithOptions is there. Happy to send a PR for whichever you prefer.

How this was found

By a research tool that compares each native declaration against the C declaration of the function it binds. Nothing was built or executed; every file quoted is in this repository at 5.19.1, and unchanged on master.

主要言語
Java
スター
8.9k
フォーク
1.7k
平均マージ
1日 13時間
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

java-native-access/jna のほかの issue

java-native-access/jna の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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