| fbe0257b | 06-Jul-2026 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
libc/resolv: Reimplement the sortlist parser
When we switched from the BIND4 resolver to the BIND9 resolver, the sortlist parser was inadvertently disabled due to a missing #define, and nobody seeme
libc/resolv: Reimplement the sortlist parser
When we switched from the BIND4 resolver to the BIND9 resolver, the sortlist parser was inadvertently disabled due to a missing #define, and nobody seemed to notice. The sorting code remained enabled in the resolver, but there was no way to set a sort order.
Reimplement the sortlist parser, but correctly, and update the manual accordingly. The new parser accepts IPv4 and IPv6 addresses with or without a mask or prefix length, just like the old one, except IPv6 support was a bit wonky in the original code.
Fixes: 5342d17f09a8 ("Update the resolver in libc to BIND9's one.") Relnotes: yes Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D57925
show more ...
|
| ffeb5690 | 06-Jul-2026 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
libc/resolv: Refactor the configuration parser
This was previously all a single loop in res_init(), apart from option parsing which we cleaned up in a previous commit. Break it out into separate fu
libc/resolv: Refactor the configuration parser
This was previously all a single loop in res_init(), apart from option parsing which we cleaned up in a previous commit. Break it out into separate functions for reading the configuration line by line, setting the default domain, setting the search list, and adding a nameserver to the nameserver list. Sprinkle bounds checks and code comments all around.
The sortlist code, which has been disabled for the past 20 years, will be dealt with in a separate commit.
MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D57924
show more ...
|
| 9bfdfecd | 06-Jul-2026 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
libc/resolv: Refactor the option parser
Start the loop by finding the end of the option name, the name-value separator (if any), and the end of the option. Use those pointers to simplify matching t
libc/resolv: Refactor the option parser
Start the loop by finding the end of the option name, the name-value separator (if any), and the end of the option. Use those pointers to simplify matching the option name and parsing the option value, and validate option names and values more strictly. This means that:
* We no longer accept trailing garbage in an option name or value. For instance, we would previously interpret “edns0123” as “edns0” and “timeout:3xyz” as “timeout:3”. This was actually quite lucky because we also failed to recognize the newline at the end of the option line as a whitespace character.
* For options that take a numerical argument, we would previously accept negative values and treat non-numerical arguments as 0, while large numerical arguments would be capped to the option's maximum permitted value. Now, any failure to parse the argument, including overflow, results in the option being left unchanged.
MFC after: 1 week Relnotes: yes Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D57923
show more ...
|
| 702c24cc | 28-Jun-2026 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
libc/resolv: Export __res_conf_name
Add a new global variable, __res_conf_name, which is initialized to _PATH_RESCONF and used in its place by res_init(). This allows test programs (and application
libc/resolv: Export __res_conf_name
Add a new global variable, __res_conf_name, which is initialized to _PATH_RESCONF and used in its place by res_init(). This allows test programs (and applications) to select a different configuration file to read instead of /etc/resolv.conf.
PR: 220610
show more ...
|
| 507ab02d | 27-Jun-2026 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
libc/resolv: Reimplement the sortlist parser
When we switched from the BIND4 resolver to the BIND9 resolver, the sortlist parser was inadvertently disabled, and nobody noticed. The sorting code rem
libc/resolv: Reimplement the sortlist parser
When we switched from the BIND4 resolver to the BIND9 resolver, the sortlist parser was inadvertently disabled, and nobody noticed. The sorting code remained enabled in the resolver, but there was no way to set a sort order.
Reimplement the sortlist parser, but correctly, and update the documentation accordingly. The new parser accepts IPv4 and IPv6 addresses with or without a prefix length.
Fixes: 5342d17f09a8 ("Update the resolver in libc to BIND9's one.") Relnotes: yes
show more ...
|
| 9fd22951 | 25-Jun-2026 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
libc/resolv: Refactor the configuration parser
This was previously all a single loop in res_init(), apart from option parsing which we cleaned up in a previous commit. Break it out into separate fu
libc/resolv: Refactor the configuration parser
This was previously all a single loop in res_init(), apart from option parsing which we cleaned up in a previous commit. Break it out into separate functions for reading the configuration line by line, setting the default domain, setting the search list, and adding a nameserver to the nameserver list. Sprinkle bounds checks and code comments all around.
The sortlist code, which has been disabled for the past 20 years, will be dealt with in a separate commit.
MFC after: 1 week
show more ...
|
| 40e10af6 | 25-Jun-2026 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
libc/resolv: Refactor the option parser
Start the loop by finding the end of the option name, the name-value separator (if any), and the end of the option. Use those pointers to simplify matching t
libc/resolv: Refactor the option parser
Start the loop by finding the end of the option name, the name-value separator (if any), and the end of the option. Use those pointers to simplify matching the option name and parsing the option value.
This means that:
* We no longer accept trailing garbage in an option name or value. For instance, we would previously interpret “edns0123” as “edns0” and “timeout:3xyz” as “timeout:3”. This was actually quite lucky because we also failed to recognize the newline at the end of the option line as a whitespace character.
* For options that take a numerical value, we would previously happily set a numerical option to a negative value and treat non-numerical arguments as 0, while a numerical argument that happened to exceed the maximum for the option would result in the option being set to its default value. Now, any failure to parse the argument, including overflow, results in the option being set to its default value.
MFC after: 1 week
show more ...
|