[Nagiosplug-devel] Nagiosplugins 1.4.11 on HP UX

Thomas Guyot-Sionnest thomas at zango.com
Mon Feb 11 22:50:08 CET 2008


-----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-----




More information about the Devel mailing list