fix(kiss): off-by-one v clampu delky jmena zarizeni
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
26ab83a4b7
commit
5fe3367aaa
1 file changed
+4
-1
@@ -730,7 +730,10 @@ void KissModem::handleGetDeviceName() {
|
||||
char buf[96];
|
||||
int n = snprintf(buf, sizeof(buf), "%s %s", _board.getManufacturerName(), FIRMWARE_VERSION);
|
||||
if (n < 0) n = 0;
|
||||
if (n > (int)sizeof(buf)) n = sizeof(buf);
|
||||
// snprintf vraci delku BEZ koncove nuly, takze n == sizeof(buf) znamena
|
||||
// "presne se to nevleslo". `n > sizeof(buf)` to propustilo a clampovalo na
|
||||
// sizeof(buf), cimz na drat sla i ta koncova nula na buf[95].
|
||||
if (n >= (int)sizeof(buf)) n = (int)sizeof(buf) - 1;
|
||||
writeHardwareFrame(HW_RESP(HW_CMD_GET_DEVICE_NAME), (const uint8_t*)buf, n);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user