This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] hesiod_end: Do not call res_nclose(&_res) [BZ #19573]
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Anders Kaseorg <andersk at mit dot edu>
- Cc: libc-alpha at sourceware dot org
- Date: Sat, 23 Apr 2016 14:30:04 +0200
- Subject: Re: [PATCH] hesiod_end: Do not call res_nclose(&_res) [BZ #19573]
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1604221400580 dot 60537 at buzzword-bingo dot mit dot edu>
* Anders Kaseorg:
> 2016-04-22 Anders Kaseorg <andersk@mit.edu>
>
> [BZ #19573]
> * hesiod/hesiod.c (hesiod_end): Only call res_nclose(ctx->res) if
> ctx->free_res is nonnull, to prevent a crash on res_nclose(&res)
> introduced by commit 2212c1420c92a33b0e0bd9a34938c9814a56c0f7
> (Simplify handling of nameserver configuration in resolver).
>
> diff --git a/hesiod/hesiod.c b/hesiod/hesiod.c
> index 657dabe..a540382 100644
> --- a/hesiod/hesiod.c
> +++ b/hesiod/hesiod.c
> @@ -152,12 +152,12 @@ hesiod_end(void *context) {
> struct hesiod_p *ctx = (struct hesiod_p *) context;
> int save_errno = errno;
>
> - if (ctx->res)
> + if (ctx->res && ctx->free_res) {
> res_nclose(ctx->res);
> + (*ctx->free_res)(ctx->res);
> + }
Please use GNU style (braces on separate lines, two-space
indentation).
> free(ctx->RHS);
> free(ctx->LHS);
> - if (ctx->res && ctx->free_res)
> - (*ctx->free_res)(ctx->res);
This is one way to fix this bug. Its correctness depends on whether
we export in any way the hesiod functionality. I thought we did, but
libhesiod is actually a separate thing, and checking with eu-readelf,
I don't see any exports of the helper functions.
If there are no external users of the callback mechanism, we do not
have to worry about the behavioral change.
I would welcome a quick double-check on this aspect.