Skip to content

Commit 64da2b4

Browse files
committed
limit user input to a max allowed length during prompt
1 parent 43894ad commit 64da2b4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Managers/UserInputManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ std::string UserInputManager::getLine(bool onlyNumber /* = false */) {
2828
continue;
2929
}
3030

31+
if (result.size() >= MAX_ALLOWED_INPUT_LENGTH) {
32+
continue;
33+
}
34+
3135
// Only number
3236
if (onlyNumber && !std::isdigit(c)) {
3337
continue;

src/Managers/UserInputManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ class UserInputManager {
4747
ITerminalView& terminalView;
4848
IInput& terminalInput;
4949
ArgTransformer& argTransformer;
50+
51+
const size_t MAX_ALLOWED_INPUT_LENGTH = 256;
5052
};

0 commit comments

Comments
 (0)