From d0426f9eddbbfb450150dbf82ae011a22266dd90 Mon Sep 17 00:00:00 2001 From: Luca Borzacchiello Date: Sun, 11 Jun 2023 12:38:28 +0200 Subject: [PATCH] Fix arguments alignment in PYC disassembler (#3569) --- librz/asm/arch/pyc/pyc_dis.c | 2 +- test/db/formats/pyc | 56 ++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/librz/asm/arch/pyc/pyc_dis.c b/librz/asm/arch/pyc/pyc_dis.c index 423e7dabfc..03096a5f54 100644 --- a/librz/asm/arch/pyc/pyc_dis.c +++ b/librz/asm/arch/pyc/pyc_dis.c @@ -48,7 +48,7 @@ int rz_pyc_disasm(RzAsmOp *opstruct, const ut8 *code, RzList /*opcodes[op], oparg, names, consts, varnames, freevars, cellvars, ops->opcode_arg_fmt); if (arg != NULL) { - rz_strbuf_appendf(&opstruct->buf_asm, "%20s", arg); + rz_strbuf_setf(&opstruct->buf_asm, "%-22s%s", name, arg); free((char *)arg); } } else if (ops->bits == 8) { diff --git a/test/db/formats/pyc b/test/db/formats/pyc index 525e9e1288..6791574ab7 100644 --- a/test/db/formats/pyc +++ b/test/db/formats/pyc @@ -173,17 +173,17 @@ EXPECT=<: - 0x0000002e LOAD_CONST Multiline strings can be written + 0x0000002e LOAD_CONST Multiline strings can be written using three "s, and are often used as documentation. ; [00] ---- section size 3248 named module - 0x00000030 STORE_NAME __doc__ - 0x00000032 LOAD_CONST True - ,=< 0x00000034 JUMP_IF_FALSE_OR_POP 10 - | 0x00000036 LOAD_CONST False + 0x00000030 STORE_NAME __doc__ + 0x00000032 LOAD_CONST True + ,=< 0x00000034 JUMP_IF_FALSE_OR_POP 10 + | 0x00000036 LOAD_CONST False `-> 0x00000038 POP_TOP - 0x0000003a LOAD_CONST False - ,=< 0x0000003c JUMP_IF_TRUE_OR_POP 18 - | 0x0000003e LOAD_CONST True + 0x0000003a LOAD_CONST False + ,=< 0x0000003c JUMP_IF_TRUE_OR_POP 18 + | 0x0000003e LOAD_CONST True `-> 0x00000040 POP_TOP EOF REGEXP_FILTER_ERR=<: - 0x0000002a LOAD_CONST Multiline strings can be written + 0x0000002a LOAD_CONST Multiline strings can be written using three "s, and are often used as documentation. ; [00] ---- section size 3218 named module - 0x0000002c STORE_NAME __doc__ - 0x0000002e LOAD_CONST True - ,=< 0x00000030 JUMP_IF_FALSE_OR_POP 10 - | 0x00000032 LOAD_CONST False + 0x0000002c STORE_NAME __doc__ + 0x0000002e LOAD_CONST True + ,=< 0x00000030 JUMP_IF_FALSE_OR_POP 10 + | 0x00000032 LOAD_CONST False `-> 0x00000034 POP_TOP - 0x00000036 LOAD_CONST False - ,=< 0x00000038 JUMP_IF_TRUE_OR_POP 18 - | 0x0000003a LOAD_CONST True + 0x00000036 LOAD_CONST False + ,=< 0x00000038 JUMP_IF_TRUE_OR_POP 18 + | 0x0000003a LOAD_CONST True `-> 0x0000003c POP_TOP EOF REGEXP_FILTER_ERR=<: - 0x0000001e LOAD_CONSTCodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module + 0x0000001e LOAD_CONST CodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module 0x00000021 MAKE_FUNCTION - 0x00000024 STORE_NAME hello_world - 0x00000027 LOAD_CONST 'world' + 0x00000024 STORE_NAME hello_world + 0x00000027 LOAD_CONST 'world' 0x0000002a PRINT_ITEM 0x0000002b PRINT_NEWLINE - 0x0000002c LOAD_NAME hello_world - 0x0000002f CALL_FUNCTION0 positional, 0 named + 0x0000002c LOAD_NAME hello_world + 0x0000002f CALL_FUNCTION 0 positional, 0 named 0x00000032 POP_TOP - 0x00000033 LOAD_CONST None + 0x00000033 LOAD_CONST None EOF REGEXP_FILTER_ERR=<: / entry0(); -| 0x0000001e LOAD_CONSTCodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module +| 0x0000001e LOAD_CONST CodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module | 0x00000021 MAKE_FUNCTION -| 0x00000024 STORE_NAME hello_world -| 0x00000027 LOAD_CONST 'world' +| 0x00000024 STORE_NAME hello_world +| 0x00000027 LOAD_CONST 'world' | 0x0000002a PRINT_ITEM | 0x0000002b PRINT_NEWLINE -| 0x0000002c LOAD_NAME hello_world -| 0x0000002f CALL_FUNCTION0 positional, 0 named +| 0x0000002c LOAD_NAME hello_world +| 0x0000002f CALL_FUNCTION 0 positional, 0 named | 0x00000032 POP_TOP -| 0x00000033 LOAD_CONST None +| 0x00000033 LOAD_CONST None \ 0x00000036 RETURN_VALUE EOF REGEXP_FILTER_ERR=<