diff options
author | Mark Wielaard <[email protected]> | 2025-06-03 01:50:07 +0200 |
---|---|---|
committer | Mark Wielaard <[email protected]> | 2025-06-03 13:44:54 +0200 |
commit | 07bd923cea4b883ca2357e9fc80babcedd242b37 (patch) | |
tree | 7c4b6a110e6dd0b0c91f1cf0230a7c3563a2c26b | |
parent | ec21fbb47e48d954835fe6ced9eed555a3e73e9f (diff) |
libcpu: riscv_disasm use 50 char mnebuf
Some "illegal" instructions can be up to 24 chars (192 bits), We'll
print this as 0x<48 hex chars>. So make sure the mnebuf is 50 chars
(no terminating zero is needed).
This shows up with _FORTIFY_SOURCE which would immediate terminate on
such "illegal" instructions. Without we just use a few extra bytes on
the stack (which aren't used afterwards, without any issue, even
though it is technically UB).
* libcpu/riscv_disasm.c (riscv_disasm): Extend char mnebuf
array to 50.
Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r-- | libcpu/riscv_disasm.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libcpu/riscv_disasm.c b/libcpu/riscv_disasm.c index 823fe9ca..0dee842a 100644 --- a/libcpu/riscv_disasm.c +++ b/libcpu/riscv_disasm.c @@ -164,7 +164,10 @@ riscv_disasm (Ebl *ebl, } char *mne = NULL; - char mnebuf[32]; + /* Max length is 24, which is "illegal", so we print it as + "0x<48 hex chars>" + See: No instruction encodings defined for these sizes yet, below */ + char mnebuf[50]; char *op[5] = { NULL, NULL, NULL, NULL, NULL }; char immbuf[32]; size_t len; |