-
Notifications
You must be signed in to change notification settings - Fork 4
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
[Robustness] Crashes if QTYPE is unknown #5
Comments
Of course, QCLASS has probably the same problem. |
For QCLASS, there is one more problem: having a closed list of classes (an exhaustive enum) will make difficult to implement later EDNS, where the "class" of the OPT resource record is the buffer size. |
Actually, the type |
I remember running into that issue when I was initially working on it. Automatically detecting if a non-exhaustive enum's value is part of the list of defined values isn't possible currently. It's not the first project where I've run into that issue. |
I asked about it a while ago, it's possible to get the same effect using a check like |
A solution would be to write a program that downloads and parses the XML version of the IANA registry of resource record types and generates the enum, plus a function converting from int to enum (if the int is known). Such code-generated Zig code would then be compiled. |
Another solution could be to add a formatter function on the Type and QType enums, and to remove |
That would probably be the easiest actually, and would prevent any other |
Actually, I already have something that does that: the function |
There are several robustness issues in zig-dns. If a DNS server using zig-dns is exposed to the public Internet, it can crash (or worse) if the incoming packet is badly formed. Such invalid packets are common on the Internet, either by mistake or as deliberate attack.
First example, when the QTYPE is unknown, instead of returning an error (or, better, the QTYPE as just a number), zig-dns crashes:
Here is the code to reproduce the issue:
Solving the problem is not easy in Zig. Ma be using non-exhaustive enums? https://ziggit.dev/t/catching-invalid-enum-value-errors/
The text was updated successfully, but these errors were encountered: