-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
The constructor in the InputText class uses strncpy
, which can lead to buffer overflows. Consider using std::copy
from the <algorithm>
library to safely copy the string and ensure null termination.
Relevant code snippet:
#include <algorithm> // Include the algorithm library
InputText(ReactImgui* view, const int id, const std::string& defaultValue, const std::string& label, std::optional<BaseStyle>& style) : StyledWidget(view, id, style) {
m_type = "InputText";
m_bufferPointer = std::make_unique<char[]>(100);
m_defaultValue = defaultValue;
m_label = label;
if (!defaultValue.empty()) {
std::copy(defaultValue.c_str(), defaultValue.c_str() + std::min(defaultValue.size(), size_t(99)), m_bufferPointer.get());
m_bufferPointer[std::min(defaultValue.size(), size_t(99))] = '\0'; // Ensure null termination
}
}
References:
PR URL: #41
Comment URL: #41 (comment)