Page MenuHomeFreeBSD

libc/resolv: Refactor the option parser
Needs ReviewPublic

Authored by des on Sun, Jun 28, 8:13 AM.
Tags
None
Referenced Files
F160880376: D57923.diff
Sun, Jun 28, 4:05 PM
Unknown Object (File)
Sun, Jun 28, 9:42 AM
Subscribers

Details

Reviewers
kevans
markj
Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 74350
Build 71233: arc lint + arc unit