Skip to content

Commit 3d98271

Browse files
committed
* CommonCLI: more reply bounds checking
1 parent db7baa7 commit 3d98271

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/helpers/CommonCLI.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
286286
// change admin password
287287
StrHelper::strncpy(_prefs->password, &command[9], sizeof(_prefs->password));
288288
savePrefs();
289-
sprintf(reply, "password now: %s", _prefs->password); // echo back just to let admin know for sure!!
289+
sprintf(reply, "password now: ");
290+
StrHelper::strncpy(&reply[14], _prefs->password, 160-15); // echo back just to let admin know for sure!!
290291
} else if (memcmp(command, "clear stats", 11) == 0) {
291292
_callbacks->clearStats();
292293
strcpy(reply, "(OK - stats reset)");
@@ -786,10 +787,11 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
786787
} else if (memcmp(config, "direct.txdelay", 14) == 0) {
787788
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->direct_tx_delay_factor));
788789
} else if (memcmp(config, "owner.info", 10) == 0) {
790+
auto start = reply;
789791
*reply++ = '>';
790792
*reply++ = ' ';
791793
const char* sp = _prefs->owner_info;
792-
while (*sp) {
794+
while (*sp && reply - start < 159) {
793795
*reply++ = (*sp == '\n') ? '|' : *sp; // translate newline back to orig '|'
794796
sp++;
795797
}

0 commit comments

Comments
 (0)