Coding - Dangerous use of 'cin' (#681)

- Replaced hardcoded buffer sizes with `constexpr size_t aBufferSize` constants
- Added `width()` calls to input streams before reading to prevent buffer overflows
- Applied consistent buffer size management across multiple input operations
This commit is contained in:
Pasukhin Dmitry
2025-08-17 21:03:18 +01:00
committed by GitHub
parent 5c8756830f
commit 5c814b0f0f
3 changed files with 18 additions and 6 deletions
@@ -3038,8 +3038,10 @@ Standard_Integer IFSelect_Functions::GiveEntityNumber(const Handle(IFSelect_Work
Standard_Integer num = 0;
if (!name || name[0] == '\0')
{
char ligne[80];
constexpr size_t aBufferSize = 80;
char ligne[aBufferSize];
ligne[0] = '\0';
std::cin.width(aBufferSize);
std::cin >> ligne;
// std::cin.clear(); std::cin.getline (ligne,79);
if (ligne[0] == '\0')