tags 690358 + patch upstream
thanks

The problem is in the original code where hostname is free()'d.
However hostname is not a valid pointer at that point for at least two
cases.  One is if it is passed as a command line argument using the
option '-h hostname'.  Neither is it a valid pointer when used with a
URL since then it is a copy of the hostname portion of the
"http://hostname/"; part of the string.  The 'free(hostname);' line is
the specific problem.

The attached patch corrects the problem.  Between 1.5.3 and 1.5.4
several free() calls were added just before the program exited.

However it is never necessary to free memory before exiting a program.
It is extra unnecessary work for the program and generally frowned
upon.  It is always more efficient and faster to let the program
memory evaporate when the process exits.  Therefore the best fix is to
remove all of the unnecessary free() calls from the program.

--- main.c.orig 2012-10-13 02:25:55.000000000 -0600
+++ main.c      2012-10-13 02:26:25.000000000 -0600
@@ -1173,11 +1173,6 @@
                return nagios_exit_code;
        }
 
-       freeaddrinfo(ai);
-       free(request);
-       free(hostname);
-       free(buffer);
-
        if (ok)
                return 0;
        else

Thanks for maintaining httping!

Bob
--- main.c.orig	2012-10-13 02:25:55.000000000 -0600
+++ main.c	2012-10-13 02:26:25.000000000 -0600
@@ -1173,11 +1173,6 @@
 		return nagios_exit_code;
 	}
 
-	freeaddrinfo(ai);
-	free(request);
-	free(hostname);
-	free(buffer);
-
 	if (ok)
 		return 0;
 	else

Reply via email to