Skip to content

missing null terminator in ud_asmprintf() #24

@DysfunctionaI

Description

@DysfunctionaI

https://github.com/spazzarama/SharpDisasm/blob/ee3af3d8aaec755208aa6782aa0eae51fd90165b/SharpDisasm/Udis86/syn.cs

Line 130:

Array.Copy(str, 0, u.asm_buf, u.asm_buf_fill, Math.Min(str.Length, avail));

Should be:

Array.Copy(str, 0, u.asm_buf, u.asm_buf_fill, Math.Min(str.Length, avail));
u.asm_buf[u.asm_buf_fill + str.Length] = '\0';

With the null terminator added correctly, then you don't need this bandaid:

https://github.com/spazzarama/SharpDisasm/blob/ee3af3d8aaec755208aa6782aa0eae51fd90165b/SharpDisasm/Udis86/udis86.cs

Line 103:
for (var i = 0; i < u.asm_buf.Length; i++)
u.asm_buf[i] = '\0';

Can now correctly match the original as:

u.asm_buf[0] = '\0';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions