otrx: check TRX length read from header to avoid Segmentation fault
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 45433
This commit is contained in:
parent
b5073ca2c8
commit
834e60c4f1
1 changed files with 6 additions and 0 deletions
|
@ -167,6 +167,12 @@ static int otrx_check() {
|
|||
}
|
||||
|
||||
length = le32_to_cpu(hdr.length);
|
||||
if (length < sizeof(hdr)) {
|
||||
fprintf(stderr, "Length read from TRX too low (%zu B)\n", length);
|
||||
err = -EINVAL;
|
||||
goto err_close;
|
||||
}
|
||||
|
||||
buf = malloc(length);
|
||||
if (!buf) {
|
||||
fprintf(stderr, "Couldn't alloc %d B buffer\n", length);
|
||||
|
|
Loading…
Reference in a new issue