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

Added support for empty salt ( aka dash ) #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MartinTerp
Copy link

When using \Badcow\DNS\Parser\Parser::parse, and the zone file contains and empty salt in the NSEC3PARAM, it throws an error:

Could not extract Rdata from resource record " 0 NSEC3PARAM 1 0 0 -"."

This is because the setSalt function in Rdata/NSEC3PARAM.php is as follows:

    public function setSalt(string $salt): void
    {
        if (false === $bin = @hex2bin($salt)) {
            throw new \InvalidArgumentException('Salt must be a hexadecimal string.');
        }
        $this->salt = $bin;
    }

This is a problem, because the salt can be empty ( dash ) but this is not support in this function.
Adding a simple check to see if its a dash, and just return, resolves this issue.

I dont know if you guys want it written differently, let me know.

This is also a issue in getSalt and fromWire

@MartinTerp
Copy link
Author

Im not a wire guy so i hope you will check that function

@samuelwilliams
Copy link
Contributor

@MartinTerp Thank you for the PR. Could you please write a test case? I'm happy to work on the fromWire method, but a test case helps alot.

@MartinTerp
Copy link
Author

Sure, do you want it in the "public function testFactory(): void" function, or its own?

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.

2 participants