Skip to content

pragma: fix NULL-pointer dereference on malformed --pragma input - #303

Open
cherry530 wants to merge 1 commit into
netwide-assembler:masterfrom
cherry530:fix-pragma-null-deref
Open

pragma: fix NULL-pointer dereference on malformed --pragma input#303
cherry530 wants to merge 1 commit into
netwide-assembler:masterfrom
cherry530:fix-pragma-null-deref

Conversation

@cherry530

Copy link
Copy Markdown

Fixes: #300

When --pragma is given with a facility but no opname (e.g.
`nasm --pragma 'str' file.asm`), nasm_get_word() returns NULL and sets the
tail pointer to NULL.  process_pragma() then calls strlen() on the NULL
tail, causing a segmentation fault (NULL dereference).

Avoid the NULL dereference and report the malformed input explicitly:

    nasm --pragma 'str' t.asm
    t.asm: error: bad argument to %pragma str: missing opname

Verified: patch applies cleanly on master, full `./configure && make`
build succeeds (exit 0).

Signed-off-by: cherry530 <707078654@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segfault (NULL deref in process_pragma) on "--pragma" with no opname

1 participant