intel/tools/aub: handle truncated input file

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8988>
This commit is contained in:
Marcin Ślusarz 2021-02-10 15:05:31 +01:00 committed by Marge Bot
parent 0893f6f03f
commit aeae177198
1 changed files with 7 additions and 1 deletions

View File

@ -316,7 +316,13 @@ aub_read_command(struct aub_read *read, const void *data, uint32_t data_len)
next += p[4] / 4;
}
assert(next <= end);
if (next > end) {
parse_error(read, data,
"input ends unexpectedly (command length: %d, remaining bytes: %d)\n",
(uintptr_t)next - (uintptr_t)data,
(uintptr_t)end - (uintptr_t)data);
return -1;
}
switch (h & 0xffff0000) {
case MAKE_HEADER(TYPE_AUB, OPCODE_AUB, SUBOPCODE_HEADER):