[Nagiosplug-devel] Nagiosplugins 1.4.11 on HP UX

ajeshb at gmail.com ajeshb at gmail.com
Mon Feb 11 22:58:05 CET 2008


_
-----Original Message-----
From: Thomas Guyot-Sionnest <thomas at zango.com>

Date: Mon, 11 Feb 2008 16:50:08 
To:Nagios Plugin Development Mailing List <nagiosplug-devel at lists.sourceforge.net>
Subject: Re: [Nagiosplug-devel] Nagiosplugins 1.4.11 on HP UX


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ton Voon wrote:
> On 11 Feb 2008, at 15:47, Holger Weiss wrote:
> 
>> * Matthias.Broenner at systemagmbh.de [2008-02-11 15:28]:
>>> cc: "utils_base.c", line 108: error 1649: Illegal integer-pointer  
>>> combination for >.
>>> cc: "utils_base.c", line 108: error 1563: Expression in if must be  
>>> scalar.
>> Ugh, that's indeed broken.  A quick and dirty workaround for you  
>> would be to
>> delete the lines 108-111 in utils_base.c:
>>
>>  if (*my_thresholds > 0) {	/* Not sure why, but sometimes could be  
>> -1 */
>>  	/* printf("Freeing here: %d\n", *my_thresholds); */
>>  	free(*my_thresholds);
>>  }
>>
>> Removing these lines creates a minor memory leak, but that won't be a
>> problem in practice.  A proper fix will require a little more work.
> 
> Ah! That's my ugly code there :(
> 
> What's a proper fix? My pointer knowledge is pretty poor...

I came across this not so long ago... since *my_thresholds is a pointer
it seemed wrong. I tried with:
  if (*my_thresholds !=  NULL) {
and I couldn't see any breakage trough automated tests...

If you could specify in which case it could be -1 that would help
although we could also explicitly ask the calling app to free (or not,
it doesn't really matter for a one-time plugin) its threshold pointer if
it needs to redefine it with set_thresholds. In most case this is called
once anyways. Typical ex. from check_cluster:

  thresholds *thresholds = NULL;
[...]
  if(process_arguments(argc,argv)==ERROR)
    usage(_("Could not parse arguments"));

  set_thresholds(&thresholds, warn_threshold, crit_threshold);

In this case (which is I believe is like every plugins that use them)
there should be no need to free it. It can be particularly dangerous is
the writer forget to initialize the pointer to NULL, as it could try
freeing random memory.

- --
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHsMMQ6dZ+Kt5BchYRApjqAJwI8+9zfyi8Q7BSHXpYs31opE4t8gCeMnY3
xjfFmroka2QCm/S6KOUqVwI=
=ADtX
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________________
Nagios Plugin Development Mailing List Nagiosplug-devel at lists.sourceforge.net
Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
::: Please include plugins version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Devel mailing list