Skip to content

TryParseReverseDomain should fail on invalid IPv4 addresses such as one octet less or more.#39

Open
zbalkan wants to merge 2 commits intoTechnitiumSoftware:masterfrom
zbalkan:fix/TryParseReverseDomain-must-accept-correct-ipv4
Open

TryParseReverseDomain should fail on invalid IPv4 addresses such as one octet less or more.#39
zbalkan wants to merge 2 commits intoTechnitiumSoftware:masterfrom
zbalkan:fix/TryParseReverseDomain-must-accept-correct-ipv4

Conversation

@zbalkan
Copy link

@zbalkan zbalkan commented Jan 29, 2026

Solves #41:

When one ore more octets are missing the Span<byte> buffer = stackalloc byte[4]; line fills it with zeroes, therefore covers the error.

When one or more octets are extra, for (int i = 0, j = parts.Length - 3; (i < 4) && (j > -1); i++, j--) loop covers as it ignores the extras.

I added an explicit guard clause for IPv4 addresses.

Copilot AI review requested due to automatic review settings January 29, 2026 17:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the TryParseReverseDomain method where invalid IPv4 reverse DNS domains were incorrectly accepted. The issue occurred because missing octets were implicitly filled with zeros due to stackalloc initialization, and extra octets were silently ignored by the loop bounds.

Changes:

  • Added explicit validation to ensure IPv4 reverse DNS domains have exactly 6 parts (4 octets + "in-addr" + "arpa")
  • Added a clear comment explaining the expected format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zbalkan zbalkan force-pushed the fix/TryParseReverseDomain-must-accept-correct-ipv4 branch from 479fe6c to a59e4a6 Compare February 3, 2026 15:31
@ShreyasZare
Copy link
Member

Regarding the copyright notice that you have added in multiple PRs. You need to remove those since any contribution that you make here, you must give up any IPR or copyright claims.

@zbalkan
Copy link
Author

zbalkan commented Feb 4, 2026

I didn't know what to do, and asked ChatGPT for GPL v3. It was the suggested way. It's okay, I can clean up. But I've got flights today, so earliest tomorrow.

BTW, what should I do with the unit tests? What should be the header? The same as others?

@ShreyasZare
Copy link
Member

I didn't know what to do, and asked ChatGPT for GPL v3. It was the suggested way. It's okay, I can clean up. But I've got flights today, so earliest tomorrow.

BTW, what should I do with the unit tests? What should be the header? The same as others?

As per GPLv3, its is not an issue. The issue is that code in this library repo is licensed separately to my employer and then some software may get sold with the source code in this repo in future. So having a IPR/copyright claim here would be an issue. Will check this further since it may be an issue with PR without the copyright notice too.

@zbalkan
Copy link
Author

zbalkan commented Feb 4, 2026

Let me know how to proceed on this.

@ShreyasZare
Copy link
Member

I didn't know what to do, and asked ChatGPT for GPL v3. It was the suggested way. It's okay, I can clean up. But I've got flights today, so earliest tomorrow.

BTW, what should I do with the unit tests? What should be the header? The same as others?

I checked more details on this. Any contribution made comes under GPLv3 so it can be used by anyone under the same license. However, name in copyright notice can only be of the person who has implemented the code, that is, made core efforts for it. Changes like typo, minor additions, incremental changes, minor features, etc. does not entitle the contributor to a add a copyright notice with their name.

The code in the repo is licensed separately to my employer and there are plans to include parts of this repo when selling software solutions which include source code and rights to use it including IPR. So, I can accept PR in here only if contributor is willing to give up any IPR/copyright claims. I am planning to add contributing guidelines to this repo so that it is clear to anyone who wish to contribute via PR.

@zbalkan
Copy link
Author

zbalkan commented Feb 6, 2026

Okay but I want to make use of Technitium in the future as I mentioned, and these can be considered my investments. At this point, do you consider a cut-off point where "version x is the last GPL3 of the library" statement would exist? Then, I can work with my fork instead by not having any issues and I can approve the IPR claims.

@ShreyasZare
Copy link
Member

Okay but I want to make use of Technitium in the future as I mentioned, and these can be considered my investments. At this point, do you consider a cut-off point where "version x is the last GPL3 of the library" statement would exist? Then, I can work with my fork instead by not having any issues and I can approve the IPR claims.

This does not stop you from using the source code and it is available under GPLv3 for everyone. This just reserves my rights to allow dual licensing such that it does not prevent me or someone I give commercial license to from selling the source code under different terms.

It would be otherwise a issue if contributors are claiming exclusive copyrights to any changes they make. That will prevent me from using my code base for other businesses. The other parties wont be willing to get into agreement when there are multiple claims for the source code.

The library code you see here, I have been writing it since 2008 and have made huge investments till now. Thus I am in my right to protect my interests. If someone does not agree to the contributing terms that I have published today in this repo then that is fine and they can fork and have their own changes under GPLv3. I just don't want legal issues later that stop me from using my own code that I have worked hard for almost two decades.

@zbalkan
Copy link
Author

zbalkan commented Feb 6, 2026

As the sole owner of the Technitium Library, you have all the rights to replace GPLv3 to commercial. And that's my worst case scenario. If that's not the case, I have no other problem.

@ShreyasZare
Copy link
Member

As the sole owner of the Technitium Library, you have all the rights to replace GPLv3 to commercial. And that's my worst case scenario. If that's not the case, I have no other problem.

GPLv3 is not getting replaced, dual-licenses can co-exist like it they currently are.

I periodically copy code from here, removing the GPLv3 license header, to be used in commercial projects at day job. This gives my employer rights to commercially use that source code. If I accept a PR with contributor's copyright notice, I wont be able to simply remove the copyright notice anymore. Which is why the contributing terms comes into picture and are required.

@zbalkan
Copy link
Author

zbalkan commented Feb 6, 2026

If the dual license is the way in the future as well, then I am fine with the conditions. Let me know which way suits better for you.

@ShreyasZare
Copy link
Member

If the dual license is the way in the future as well, then I am fine with the conditions. Let me know which way suits better for you.

It is currently having dual license and it will remain the same in future too.

@zbalkan
Copy link
Author

zbalkan commented Feb 6, 2026

Then, it'd be better adding a CONTRIBUTING.md file mentioning the dual license, and each PR accepts this. So, it will be transparent. Otherwise, it looks fair.

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