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

外部コマンド実行ダイアログのコマンド文字列バッファ長が1文字大きい不具合の対応 #1584

Merged

Conversation

usagisita
Copy link
Contributor

PR の目的

外部コマンド実行ダイアログのコマンドに最大の1024文字ちょうどを入力(NULL含まない)すると、コマンドは実行されますが、履歴に登録されません。
このPRではダイアログの配列サイズを1024+1から1024に修正することにより、必ず履歴に登録されるように制限します。

カテゴリ

  • 不具合修正
  • プログラムの動作上の問題
    • 正式リリース版

PR の背景

動作が一貫していなくて、変な感じがすると思います。

PR のメリット

エッジケースの微妙な動作を修正できます。

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

1文字コマンド入力できる文字数が以前より減ります。

仕様・動作説明

履歴側の配列サイズは
typedef StaticString<WCHAR, MAX_CMDLEN> CCmdString;
と定義されていて、MAX_CMDLENがそのまま配列サイズになります。
履歴登録処理では入力チェック機構があり、そこで文字列長の確認があり、1文字長いためにはじかれて履歴に登録されないようです。
(ここはバッファを突き抜けたりはしていません)

CEditView::ExecCmd側にはさらにバッファオーバーランの問題がありますが、それは別で対処したいと思います。

PR の影響範囲

1文字コマンド入力できる文字数が以前より減ります。
CDlgExecの実装コード側は_countofなどが使われているため、特に修正は問題ないようです。

テスト内容

テスト1

手順
外部コマンド実行ダイアログで「名前」に1024文字(NULL含まない)を入力します。実行します。
再度ダイアログか履歴画面で見ても履歴に登録されていません。

コード修正後は最大文字数が1023文字になります。実行後にダイアログを再表示すると履歴に登録されています。

関連 issue, PR

参考資料

@sonarcloud
Copy link

sonarcloud bot commented Mar 13, 2021

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@AppVeyorBot
Copy link

Build sakura 1.0.3544 completed (commit a19a553df5 by @usagisita)

@usagisita
Copy link
Contributor Author

迅速な確認ありがとうございます。

@usagisita usagisita merged commit 0417782 into sakura-editor:master Mar 13, 2021
@usagisita usagisita deleted the feature/fix_buffer_exec_dlg branch March 13, 2021 14:44
@beru beru added the 🐛bug🦋 ■バグ修正(Something isn't working) label Mar 21, 2021
This pull request was closed.
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.

5 participants