Skip to content

dhcp.py returns 0 value in parse_dhcp_response(), causes dhcp_state_machine() to raise exception #79

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

Closed
schaefer01 opened this issue Dec 15, 2022 · 3 comments

Comments

@schaefer01
Copy link

hi,
I've got a firewall issue, parse_dhcp_response() fails and returns 0, but dhcp_state_machine() does not
test for error response, assumes a value uses the value in a conditional statement, and raises this exception:

object with buffer protocol required

the code is here:
elif self._dhcp_state == STATE_DHCP_REQUEST:
if self._sock.available():
if self._debug:
print("* DHCP: Parsing ACK")
msg_type, xid = self.parse_dhcp_response()
# Check if transaction ID matches, otherwise it may be
# for another device
if htonl(self._transaction_id) == int.from_bytes(xid, "big"): <------- exception raised here

@schaefer01
Copy link
Author

as a side note, there are mutiple different error paths in parse_dhcp_response() that all return 0's
it would be nice to have a diagnostic to indicate which failure path is taken when a failure occurs

@anecdata
Copy link
Member

@schaefer01 Can you re-test the code from PR 80 and confirm it solves your issue?

@schaefer01
Copy link
Author

hi,
yes, thank you.
bob s.

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