Skip to content

Fixed a TypeError in adafruit_wiznet5k_dns.DNS._build_dns_question() #72

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

Merged
merged 1 commit into from
Nov 2, 2022
Merged

Fixed a TypeError in adafruit_wiznet5k_dns.DNS._build_dns_question() #72

merged 1 commit into from
Nov 2, 2022

Conversation

BiffoBear
Copy link
Contributor

closes #71 Fix is self._pkt_buf += bytes(host[i], "utf-8")

Code snippet with bug below.

adafruit_wiznet5k/adafruit_wiznet5k_dns.py
        
    def _build_dns_question(self) -> None:
        """Build a DNS query."""
        host = self._host.decode("utf-8")
        host = host.split(".")
        # write out each section of host
        for i, _ in enumerate(host):
            # append the sz of the section
            self._pkt_buf.append(len(host[i]))
            # append the section data
            self._pkt_buf += host[i]     # <-------
        # end of the name
        self._pkt_buf.append(0x00)
        # Type A record
        self._pkt_buf.append(htons(TYPE_A) & 0xFF)
        self._pkt_buf.append(htons(TYPE_A) >> 8)
        # Class IN
        self._pkt_buf.append(htons(CLASS_IN) & 0xFF)
        self._pkt_buf.append(htons(CLASS_IN) >> 8)

Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@tekktrik tekktrik merged commit 859c93b into adafruit:main Nov 2, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 3, 2022
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.

DNS server raises TypeError exception in C Python although it runs in CP
2 participants