[Nagiosplug-devel] [ nagiosplug-Bugs-1310495 ] check_snmp.c Doesn't Compile on RH7.3

SourceForge.net noreply at sourceforge.net
Fri Jan 13 14:14:01 CET 2006


Bugs item #1310495, was opened at 2005-10-01 14:09
Message generated for change (Comment added) made by cjorsinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1310495&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Craig Orsinger (cjorsinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: check_snmp.c Doesn't Compile on RH7.3

Initial Comment:
Because there's a local variable declared in the middle
of a while loop, this source file won't compile on
RedHat 7.3. The error was introduced in nagios-plugins
version 1.4.1, and still exists in version 1.4.2.

I've attempted to attach a patch file that fixes this.


----------------------------------------------------------------------

>Comment By: Craig Orsinger (cjorsinger)
Date: 2006-01-13 14:13

Message:
Logged In: YES 
user_id=1261217

Thanks, alierak.

It looks like they're not using the asprintf() function
correctly. It appears, based on the man page and some
experimentation, that you're supposed to pass it the address
of an empty string pointer, and then free() that string once
you're done with it. This isn't what they're doing. In fact,
they use asprintf several times in this same source file
without freeing the strings. I'm surprised they haven't
noticed memory leak problems in this plugin.

I'm not sure what the best way to fix the problem is, but
I'm attempting to attach your fix as a patch. My original
was a quick fix for the immediate issue, which was just
getting the thing to build so I could try it out. I can't
try to fix this right now, because my network's in disarray
and I don't have nagios running on it.


----------------------------------------------------------------------

Comment By: Robby Griffin (alierak)
Date: 2006-01-13 11:35

Message:
Logged In: YES 
user_id=83996

Well, no, sourceforge won't let me attach a file to someone else's bug report, 
so here you go:

--- nagios-plugins-1.4.2/plugins/check_snmp.c.orig      Wed Jun  1 15:41:
01 2005
+++ nagios-plugins-1.4.2/plugins/check_snmp.c   Thu Jan 12 18:22:
47 2006
@@ -337,10 +337,17 @@
                        asprintf (&outbuff, "%s %s", outbuff, unitv[i]);
 
                i++;
-
+#if 0
                char *str[MAX_INPUT_BUFFER];
                asprintf(str, "=%s%s;;;; ", show, type ? type : "");
                strcat(perfstr, *str);
+#else
+               strcat(perfstr, "=");
+               strcat(perfstr, show);
+               if (type)
+                       strcat(perfstr, type);
+               strcat(perfstr, ";;;; ");
+#endif
 
        }       /* end while (ptr) */
 


----------------------------------------------------------------------

Comment By: Robby Griffin (alierak)
Date: 2006-01-13 11:33

Message:
Logged In: YES 
user_id=83996

Still exists in CVS, too, and also won't compile on NetBSD 1.6.

I don't like this variable declaration at all, btw, because it's an array of 
pointers to strings, which the program then uses as if it were a pointer to a 
string. I'll attach an alternate patch which eliminates the declaration entirely.

----------------------------------------------------------------------

Comment By: Jeremy D Pavleck (judg3)
Date: 2005-11-18 21:50

Message:
Logged In: YES 
user_id=510182

exact same problem on Solaris 9.
The patch fixed it.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1310495&group_id=29880




More information about the Devel mailing list