diag_read_msg(): Discard any messages shorter than 3 bytes
The 16bit CRC and the FLAG octet together are 3 bytes. If a message is shorter than that, something is going wrong, for sure.
This commit is contained in:
parent
4ae0936123
commit
a115fbb1bb
|
@ -123,6 +123,12 @@ struct msgb *diag_read_msg(struct diag_instance *di)
|
|||
|
||||
if (rc == HDLC_COMPLETE) {
|
||||
di->rx.msg = NULL;
|
||||
|
||||
if (msgb_length(msg) < 3) {
|
||||
msgb_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = crc_check(msgb_data(msg), msgb_length(msg));
|
||||
if (rc) {
|
||||
fprintf(stderr, "Bad CRC, dropping packet\n");
|
||||
|
|
Loading…
Reference in New Issue