Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid instruction is executed #12

Closed
disconnect3d opened this issue Oct 17, 2018 · 1 comment
Closed

Invalid instruction is executed #12

disconnect3d opened this issue Oct 17, 2018 · 1 comment

Comments

@disconnect3d
Copy link
Contributor

After:

> mov qword [rsp-0x1234], 0x1122334455667788
> mov qword rbx, [rsp-0x1234]

The result in rbx is:

rbx: 0x0000000055667788

The fact is that the first instruction is not really valid as the operand size is too big. Actually it prints out a warning about it, but it is super easy to miss it:

> mov qword [rsp-0x1234], 0x1122334455667788
/dev/fd/3:3: warning: signed dword immediate exceeds bounds [-w+number-overflow]
/dev/fd/3:3: warning: dword data exceeds bounds [-w+number-overflow]

Can we make this warning an error and not continue on that?

@yrp604 yrp604 closed this as completed in b727154 Oct 18, 2018
@yrp604
Copy link
Owner

yrp604 commented Oct 18, 2018

Hey, thanks for the bug report.

I've changed the behavior here a bit: after piping user input to nasm we now capture both stdout (the bytecode) and stderr (warnings). If anything is written to stderr, we dump it and truncate the bytecode length to 0 so the state will be unchanged. In pipe mode this is an error and we exit(1). UI mode treats it as an assembly failure basically -- previously we would have warned and executed nasms best effort at assembling the instruction, now we warn and don't execute anything. I'd rather not make it an error, because the ui quitting due to the user entering an invalid instruction like this could be very annoying.

Does this work for you?

PS: I also found an fd leak when changing this :)

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

No branches or pull requests

2 participants