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

rpc: handle denied replies #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

rpc: handle denied replies #5

wants to merge 1 commit into from

Conversation

cnotin
Copy link

@cnotin cnotin commented Sep 27, 2019

RPC reply bodies can be either MSG_ACCEPTED or MSG_DENIED:
https://www.rfc-editor.org/rfc/rfc1831.html#page-11

MSG_ACCEPTED are 24 bytes long (6 fields of 4 bytes):
image
This is correctly handled by current code.

MSG_DENIED however are shorter, 20 bytes (5 fields of 4 bytes):
image

So struct.unpack('!LLLLLL', rpc) fails on MSG_DENIED replies (not enough data to unpack).
The proposed patch only unpacks the first 3 fields, checks if it's a MSG_DENIED and exits then, then only unpack the rest if it's a MSG_ACCEPTED
This is similar to this: https://github.com/nmap/nmap/blob/1ae88d2620a31639018e649c5353fa4b24387262/nselib/rpc.lua#L389

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.

1 participant