twisted / twisted/twisted

t.n.common.extractRecord ineffectually checks for socket.inet_ntop

Open
#9,753 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug names new priority-low
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

twm's avatar @twm reported
Trac ID trac#9753
Type defect
Created 2020-01-08 04:39:47Z

From twisted.names.common.extractRecord():

    if hasattr(socket, 'inet_ntop'):
        for r in answers:
            if r.name == name and r.type == dns.A6:
                return socket.inet_ntop(socket.AF_INET6, r.payload.address)
        for r in answers:
            if r.name == name and r.type == dns.AAAA:
                return socket.inet_ntop(socket.AF_INET6, r.payload.address)
    for r in answers:
        if r.name == name and r.type == dns.A:
            return socket.inet_ntop(socket.AF_INET, r.payload.address)

The hasattr() check is ineffectual for two reasons:

  1. twisted.python.compat monkeypatches this method, so it is always present.
  2. The processing of A records uses this function outside the block protected by the check.

Remove the check.

Searchable metadata
trac-id__9753 9753
type__defect defect
reporter__twm twm
priority__low low
milestone__None None
branch__ 
branch_author__ 
status__new new
resolution__None None
component__names names
keywords__None None
time__1578458387989425 1578458387989425
changetime__1578458387989425 1578458387989425
version__None None
owner__None None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at twisted.names.common.extractRecord(), where the issue identifies the ineffective socket.inet_ntop check. Remove that check, then inspect the existing tests covering A, A6, and AAAA records to verify the lookup behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.