* CommonCLI: more reply bounds checking
This commit is contained in:
committed by
Matthias Wientapper
parent
06e0273e1f
commit
aa796e8623
@@ -286,7 +286,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
|||||||
// change admin password
|
// change admin password
|
||||||
StrHelper::strncpy(_prefs->password, &command[9], sizeof(_prefs->password));
|
StrHelper::strncpy(_prefs->password, &command[9], sizeof(_prefs->password));
|
||||||
savePrefs();
|
savePrefs();
|
||||||
sprintf(reply, "password now: %s", _prefs->password); // echo back just to let admin know for sure!!
|
sprintf(reply, "password now: ");
|
||||||
|
StrHelper::strncpy(&reply[14], _prefs->password, 160-15); // echo back just to let admin know for sure!!
|
||||||
} else if (memcmp(command, "clear stats", 11) == 0) {
|
} else if (memcmp(command, "clear stats", 11) == 0) {
|
||||||
_callbacks->clearStats();
|
_callbacks->clearStats();
|
||||||
strcpy(reply, "(OK - stats reset)");
|
strcpy(reply, "(OK - stats reset)");
|
||||||
@@ -786,10 +787,11 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
|
|||||||
} else if (memcmp(config, "direct.txdelay", 14) == 0) {
|
} else if (memcmp(config, "direct.txdelay", 14) == 0) {
|
||||||
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->direct_tx_delay_factor));
|
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->direct_tx_delay_factor));
|
||||||
} else if (memcmp(config, "owner.info", 10) == 0) {
|
} else if (memcmp(config, "owner.info", 10) == 0) {
|
||||||
|
auto start = reply;
|
||||||
*reply++ = '>';
|
*reply++ = '>';
|
||||||
*reply++ = ' ';
|
*reply++ = ' ';
|
||||||
const char* sp = _prefs->owner_info;
|
const char* sp = _prefs->owner_info;
|
||||||
while (*sp) {
|
while (*sp && reply - start < 159) {
|
||||||
*reply++ = (*sp == '\n') ? '|' : *sp; // translate newline back to orig '|'
|
*reply++ = (*sp == '\n') ? '|' : *sp; // translate newline back to orig '|'
|
||||||
sp++;
|
sp++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user