Re: [Nagios-devel] [PATCH 3/4] base/nerd: Fix crash during shutdown

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] [PATCH 3/4] base/nerd: Fix crash during shutdown

Post by Guest »

On 11/27/2012 05:41 PM, robin.sonefors@op5.com wrote:
> From: Robin Sonefors
>
> If opathchecks had been used, the cleanup code didn't properly zero the
> host_parent_path_cache pointer, meaning it would dangle and cause
> crashes the next time it was used.
>
> Signed-off-by: Robin Sonefors
> ---
> base/nerd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/base/nerd.c b/base/nerd.c
> index 05a0953..e0cf6a5 100644
> --- a/base/nerd.c
> +++ b/base/nerd.c
> @@ -254,7 +254,7 @@ static int chan_service_checks(int cb, void *data)
> return 0;
> }
>
> -static char **host_parent_path_cache;
> +static char **host_parent_path_cache = NULL;

This is unnecessary, as the .bss segment is implicitly zero'd out at
program loadtime.

> static const char *host_parent_path(host *leaf, char sep)
> {
> char *ret;
> @@ -341,7 +341,7 @@ static int nerd_deinit(void)
> for(i = 0; i my_free(host_parent_path_cache);
> }
> - free(host_parent_path_cache);
> + my_free(host_parent_path_cache);
> }
>

This is a good catch though. Applied (with mentioned modifications).
Thanks.

--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: ae@op5.se
Locked