mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] Fix attempts option not being respected from resolv.conf
@ 2017-04-03 23:15 Stefan Sedich
  2017-04-21 21:37 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Sedich @ 2017-04-03 23:15 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

After some extensive digging it looks like the attempts option is not being
used properly in resolv.conf, turns out there is a subtle bug and it does
not appear to read the value correctly.

Looking at the old code this did work but must have broken when the
resolv.conf reading was refactored out, below is the fix for this (first
time submitting a patch here so hopefully I am doing it right).

---
 src/network/resolvconf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
index 2cf1f475..4c3e4c4b 100644
--- a/src/network/resolvconf.c
+++ b/src/network/resolvconf.c
@@ -45,8 +45,8 @@ int __get_resolv_conf(struct resolvconf *conf, char
*search, size_t search_sz)
  if (z != p) conf->ndots = x > 15 ? 15 : x;
  }
  p = strstr(line, "attempts:");
- if (p && isdigit(p[6])) {
- p += 6;
+ if (p && isdigit(p[9])) {
+ p += 9;
  unsigned long x = strtoul(p, &z, 10);
  if (z != p) conf->attempts = x > 10 ? 10 : x;
  }
-- 
2.11.0

[-- Attachment #2: Type: text/html, Size: 2037 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix attempts option not being respected from resolv.conf
  2017-04-03 23:15 [PATCH] Fix attempts option not being respected from resolv.conf Stefan Sedich
@ 2017-04-21 21:37 ` Rich Felker
  2017-04-21 21:39   ` Stefan Sedich
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2017-04-21 21:37 UTC (permalink / raw)
  To: musl

On Mon, Apr 03, 2017 at 11:15:12PM +0000, Stefan Sedich wrote:
> After some extensive digging it looks like the attempts option is not being
> used properly in resolv.conf, turns out there is a subtle bug and it does
> not appear to read the value correctly.
> 
> Looking at the old code this did work but must have broken when the
> resolv.conf reading was refactored out, below is the fix for this (first
> time submitting a patch here so hopefully I am doing it right).
> 
> ---
>  src/network/resolvconf.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
> index 2cf1f475..4c3e4c4b 100644
> --- a/src/network/resolvconf.c
> +++ b/src/network/resolvconf.c
> @@ -45,8 +45,8 @@ int __get_resolv_conf(struct resolvconf *conf, char
> *search, size_t search_sz)
>   if (z != p) conf->ndots = x > 15 ? 15 : x;
>   }
>   p = strstr(line, "attempts:");
> - if (p && isdigit(p[6])) {
> - p += 6;
> + if (p && isdigit(p[9])) {
> + p += 9;
>   unsigned long x = strtoul(p, &z, 10);
>   if (z != p) conf->attempts = x > 10 ? 10 : x;
>   }

Looks fine, but your mailer botched the patch formatting. I've applied
it by hand and added a reference to the commit responsible for the
regression. Thanks.

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix attempts option not being respected from resolv.conf
  2017-04-21 21:37 ` Rich Felker
@ 2017-04-21 21:39   ` Stefan Sedich
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Sedich @ 2017-04-21 21:39 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]

Thanks Rich,

I have a V2 where I fixed this up as I made a mess of the first one as you
can see, thanks for getting it in :)



Stefan

On Fri, Apr 21, 2017 at 2:37 PM Rich Felker <dalias@libc.org> wrote:

> On Mon, Apr 03, 2017 at 11:15:12PM +0000, Stefan Sedich wrote:
> > After some extensive digging it looks like the attempts option is not
> being
> > used properly in resolv.conf, turns out there is a subtle bug and it does
> > not appear to read the value correctly.
> >
> > Looking at the old code this did work but must have broken when the
> > resolv.conf reading was refactored out, below is the fix for this (first
> > time submitting a patch here so hopefully I am doing it right).
> >
> > ---
> >  src/network/resolvconf.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/network/resolvconf.c b/src/network/resolvconf.c
> > index 2cf1f475..4c3e4c4b 100644
> > --- a/src/network/resolvconf.c
> > +++ b/src/network/resolvconf.c
> > @@ -45,8 +45,8 @@ int __get_resolv_conf(struct resolvconf *conf, char
> > *search, size_t search_sz)
> >   if (z != p) conf->ndots = x > 15 ? 15 : x;
> >   }
> >   p = strstr(line, "attempts:");
> > - if (p && isdigit(p[6])) {
> > - p += 6;
> > + if (p && isdigit(p[9])) {
> > + p += 9;
> >   unsigned long x = strtoul(p, &z, 10);
> >   if (z != p) conf->attempts = x > 10 ? 10 : x;
> >   }
>
> Looks fine, but your mailer botched the patch formatting. I've applied
> it by hand and added a reference to the commit responsible for the
> regression. Thanks.
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 2112 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-21 21:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03 23:15 [PATCH] Fix attempts option not being respected from resolv.conf Stefan Sedich
2017-04-21 21:37 ` Rich Felker
2017-04-21 21:39   ` Stefan Sedich

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).