Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SonarCloudにBugだと言われているGetExistPathWの範囲外アクセスを修正する #1594

Merged

Conversation

berryzplus
Copy link
Contributor

PR の目的

SonarCloudの警告により発覚した潜在不具合(?)を修正します。

カテゴリ

  • 不具合修正

PR の背景

SonarCloudにより以下のBugsレベル警告が検出されています。

Out of bound memory access (accessed memory precedes memory block)
https://sonarcloud.io/project/issues?id=sakura-editor_sakura&issues=AWzTrq7uQSy0V0BNOlDQ&open=AWzTrq7uQSy0V0BNOlDQ

/* ↓ルートディレクトリを引っかけるための処理 */
if( ( *pw == L'\\' )&&( *(pw-1) == L':' ) ){ /* C:\ とかの \ っぽい */
* (pw+1) = L'\0'; /* \ の後ろの位置を文字列の終端にする。 */
if( _waccess(po,0) == 0 ) break; /* 有効なパス文字列が見つかった */
}

このコードは pw = ps + 0 のときにも通るので、 ノーチェックで pw - 1 にアクセスするのはマズいです。
※psには書き込み先バッファの先頭アドレスが入ってるっぽいです。

PR のメリット

SonarCloudのBugsレベル警告が1つ解消します。

PR のデメリット (トレードオフとかあれば)

とくにありません。

仕様・動作説明

pw - 1 にアクセスする前にチェックを入れます。

PR の影響範囲

テスト内容

ビルド確認のみです。

関連 issue, PR

#1504

参考資料

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@AppVeyorBot
Copy link

@berryzplus
Copy link
Contributor Author

レビューありがとうございます。マージしちゃいます。

@berryzplus berryzplus merged commit 32689c5 into sakura-editor:master Mar 20, 2021
@berryzplus berryzplus deleted the feature/fix_GetExistPathW branch March 20, 2021 09:13
@beru beru added the 🐛bug🦋 ■バグ修正(Something isn't working) label Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug🦋 ■バグ修正(Something isn't working)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants