Skip to content

Fix heap corruption when saving library images from the webview - #501

Merged
qnst merged 1 commit into
masterfrom
Double
Oct 23, 2026
Merged

qnst merged 1 commit into
masterfrom
Double

Conversation

@qnst

@qnst qnst commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 05:02
@qnst
qnst merged commit f9352dd into master Oct 23, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The allocation-size calculation introduces signed integer overflow for large positive message-supplied image lengths.

1 open issue
What changed in this PR

This PR addresses heap corruption when saving library images received from the webview.

Changes:

  • Extracts the image payload directly from the JSON string without adding serialization quotes.
  • Bounds Base64 decoding and writes the returned byte count.
  • Adds validation and error handling for allocation and file operations.
File Description
T3000/​BacnetWebView.cpp Updates image-save handling and adds output bounds to the Base64 decoder.

Review effort: Balanced

Comment thread T3000/BacnetWebView.cpp
if (temp_ret == NULL)
// The buffer is sized from the reported length and the decoder is bounded by it,
// so a malformed/truncated payload can never overrun the allocation.
char* ret_result = (char*)malloc(sizeof(char) * (file_length + 4)); //申请返回字符串空间
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants