Skip to content

Improve errmsg buffer handling in DataManager::Error#2837

Closed
salix5 wants to merge 1 commit into
Fluorohydride:masterfrom
salix5:patch45
Closed

Improve errmsg buffer handling in DataManager::Error#2837
salix5 wants to merge 1 commit into
Fluorohydride:masterfrom
salix5:patch45

Conversation

@salix5

@salix5 salix5 commented Jun 12, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@salix5 salix5 requested a review from Copilot June 12, 2025 10:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aims to improve the error message handling in DataManager::Error by updating the buffer copy mechanism.

  • Refactored error message copying from using std::strncat to std::strncpy.
  • Added explicit null-termination of the buffer after copying.

Comment thread gframe/data_manager.cpp
Comment on lines +168 to +169
std::strncpy(errmsg, sqlite3_errmsg(pDB), sizeof errmsg - 1);
errmsg[sizeof errmsg - 1] = 0;

Copilot AI Jun 12, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Consider using a safer string copy approach such as std::snprintf (if available) or a dedicated safe string copy utility to reduce the risk of truncation issues, even though the manual null-termination is handled on the next line.

Suggested change
std::strncpy(errmsg, sqlite3_errmsg(pDB), sizeof errmsg - 1);
errmsg[sizeof errmsg - 1] = 0;
std::snprintf(errmsg, sizeof errmsg, "%s", sqlite3_errmsg(pDB));

Copilot uses AI. Check for mistakes.
@salix5 salix5 closed this Jun 12, 2025
@salix5 salix5 deleted the patch45 branch June 12, 2025 11:02
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.

2 participants