svn commit: r338289 - stable/11/sys/kern
Kyle Evans
kevans at FreeBSD.org
Fri Aug 24 02:21:15 UTC 2018
Author: kevans
Date: Fri Aug 24 02:21:14 2018
New Revision: 338289
URL: https://svnweb.freebsd.org/changeset/base/338289
Log:
MFC r338020: res_find: Fix fallback logic
The fallback logic was broken if hints were found in multiple environments.
If we found a hint in either the loader environment or the static
environment, fallback would be incremented excessively when we returned to
the environment-selection bits. These checks should have also been guarded
by the fbacklvl checks. As a result, fbacklvl could quickly get to a point
where we skip either the static environment and/or the static hints
depending on which environments contained valid hints.
The impact of this bug is minimal, mostly affecting mips boards that use
static hints and may have hints in either the loader environment or the
static environment.
There may be better ways to express the searchable environments and
describing their characteristics (immutable, already searched, etc.) but
this may be revisited after 12 branches.
Modified:
stable/11/sys/kern/subr_hints.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/kern/subr_hints.c
==============================================================================
--- stable/11/sys/kern/subr_hints.c Fri Aug 24 01:59:25 2018 (r338288)
+++ stable/11/sys/kern/subr_hints.c Fri Aug 24 02:21:14 2018 (r338289)
@@ -172,30 +172,37 @@ fallback:
if (dyn_used || fbacklvl >= FBACK_STATIC)
return (ENOENT);
- if (fbacklvl <= FBACK_MDENV &&
- _res_checkenv(md_envp)) {
- hintp = md_envp;
- goto found;
- }
- fbacklvl++;
+ switch (fbacklvl) {
+ case FBACK_MDENV:
+ fbacklvl++;
+ if (_res_checkenv(md_envp)) {
+ hintp = md_envp;
+ break;
+ }
- if (!stenv_skip && fbacklvl <= FBACK_STENV &&
- _res_checkenv(kern_envp)) {
- hintp = kern_envp;
- goto found;
- } else
- stenv_skip = true;
+ /* FALLTHROUGH */
+ case FBACK_STENV:
+ fbacklvl++;
+ if (!stenv_skip && _res_checkenv(kern_envp)) {
+ hintp = kern_envp;
+ break;
+ } else
+ stenv_skip = true;
- fbacklvl++;
+ /* FALLTHROUGH */
+ case FBACK_STATIC:
+ fbacklvl++;
+ /* We'll fallback to static_hints if needed/can */
+ if (!sthints_skip &&
+ _res_checkenv(static_hints))
+ hintp = static_hints;
+ else
+ sthints_skip = true;
- /* We'll fallback to static_hints if needed/can */
- if (!sthints_skip && fbacklvl <= FBACK_STATIC &&
- _res_checkenv(static_hints))
- hintp = static_hints;
- else
- sthints_skip = true;
-found:
- fbacklvl++;
+ break;
+ default:
+ return (ENOENT);
+ }
}
if (hintp == NULL)
More information about the svn-src-all
mailing list