From 0424017e7267106bde773b1e5516c5d9c4a8f84b Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Wed, 16 Aug 2023 21:36:43 +0900 Subject: [PATCH] asahi: decode: Do not assert on buffer overruns This kills the hypervisor, let's just print and return. Also flush after decoding, so that if something else goes wrong at least we get the logs up to that point. Signed-off-by: Asahi Lina Part-of: --- src/asahi/lib/decode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index b43ad34..03a6aac 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -486,10 +486,13 @@ agxdecode_usc(const uint8_t *map, UNUSED uint64_t *link, UNUSED bool verbose, #define PPP_PRINT(map, header_name, struct_name, human) \ if (hdr.header_name) { \ - assert(((map + AGX_##struct_name##_LENGTH) <= (base + size)) && \ - "buffer overrun in PPP update"); \ + if (((map + AGX_##struct_name##_LENGTH) > (base + size))) { \ + fprintf(agxdecode_dump_stream, "Buffer overrun in PPP update\n"); \ + return; \ + } \ DUMP_CL(struct_name, map, human); \ map += AGX_##struct_name##_LENGTH; \ + fflush(agxdecode_dump_stream); \ } static void -- 2.7.4