Page MenuHomeFreeBSD

libc/resolv: Refactor the configuration parser
AcceptedPublic

Authored by des on Sun, Jun 28, 8:13 AM.
Tags
None
Referenced Files
F161104645: D57924.diff
Tue, Jun 30, 2:24 PM
F161102721: D57924.diff
Tue, Jun 30, 2:06 PM
F161102714: D57924.diff
Tue, Jun 30, 2:06 PM
F161102539: D57924.diff
Tue, Jun 30, 2:04 PM
F161101581: D57924.id180853.diff
Tue, Jun 30, 1:52 PM
F161096963: D57924.id180858.diff
Tue, Jun 30, 12:58 PM
F161021886: D57924.diff
Mon, Jun 29, 10:17 PM
Unknown Object (File)
Mon, Jun 29, 9:19 AM
Subscribers

Details

Reviewers
kevans
markj
Summary

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

Diff Detail

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

Event Timeline

My comments are just nitpicking.

lib/libc/resolv/res_init.c
250

What is this comment format?

333

After reading res_setoptions(), I kind of prefer using chained else ifs rather than if (...) { ... continue; } for each directive.

486

I think it's not possible to have end == NULL? And the caller has set *eol = '\0' so I wonder if it's cleaner to just not pass end to these helpers at all.

581

It'd help to describe the return value. And why not use a bool?

600

Here we also can't have end == NULL.

623

Might as well print the error string too...?

This revision is now accepted and ready to land.Tue, Jun 30, 2:36 PM
lib/libc/resolv/res_init.c
250

ISC's in-house style

333

me too, but it makes it harder to cleanly #ifdef out individual stanzas

486

You're right, res_ninit() originally passed NULL here but no longer does. The point of passing end around is that if I already have it it's cheaper to pass it than to recompute it.

581

It's technically a count...

600

Correct, there was an earlier version of the patch were we could

623

It's not very useful, we're using AI_NUMERICHOST so the only possible error is a syntax error which I think will show as “Name does not resolve”.