MacFileUtils: FSPathMakeRef passes an int where the C function takes its FSRef output pointer
まだ誰も着手していません。
評価
調査の方向性
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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
java-native-access/jna のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
java-native-access/jna#1745 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
java-native-access/jna#1747 ·
-
`Native.typeOptions` never releases library interfaces, leaking classloaders対応中かも @curforever が 10 日前に担当しました。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 48/100
java-native-access/jna#1742 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 66/100
java-native-access/jna#1738 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
java-native-access/jna#1736 ·
java-native-access/jna の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ome/ome-codecs#48 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
tonihele/OpenKeeper#672 ·
メンテナーはふだん 4 日以内に返信
-
Shaded google-api-client trust stores still include AAA Certificate Services (eMudhra CA compromise)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
snowflakedb/snowflake-jdbc#2763 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ControlSystemStudio/phoebus#3983 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
zamojski/TowerCollector#292 · コメント 1 件 ·