If htmladmin fails to connect to the server, the cgi could crash.

This patch checks the flag for the server status and avoids the
unnecessary free.

>From 4ec23c03450d45639282c173d2e095c4023876bb Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nho...@totoro.sjc.redhat.com>
Date: Fri, 23 Mar 2012 13:13:08 -0700
Subject: [PATCH] If htmladmin fails to connect to the server, the cgi could
 crash.

This patch checks the flag for the server status and avoids the
unnecessary free.
---
 admserv/cgi-src40/htmladmin.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/admserv/cgi-src40/htmladmin.c b/admserv/cgi-src40/htmladmin.c
index 09d0ad0..7110526 100644
--- a/admserv/cgi-src40/htmladmin.c
+++ b/admserv/cgi-src40/htmladmin.c
@@ -1175,8 +1175,8 @@ int output_topology(AdmldapInfo ldapInfo,
 	      char *admin_url;
 	      char *server_host;
 	      int *server_port;
-	      int running;
-	      char *href;
+	      int running = 0;
+	      char *href = NULL;
 	      char *info_link;
 	      char *log_link;
 
@@ -1232,7 +1232,10 @@ int output_topology(AdmldapInfo ldapInfo,
 
 	        free((void *)dn_escaped);
 	        free((void *)val_escaped);
-	        PR_smprintf_free((char *)href);
+	        if (running == 1) {
+	          PR_smprintf_free((char *)href);
+	          href = NULL;
+	        }
 	        PR_smprintf_free((char *)info_link);
 	        PR_smprintf_free((char *)log_link);
 	      } else if(strstr(ldap_get_dn(server, sie_entry), "Directory")) {
@@ -1276,7 +1279,9 @@ int output_topology(AdmldapInfo ldapInfo,
 	        free((void *)dn_escaped);
 	        free((void *)val_escaped);
 	        free((void *)host_escaped);
-	        PR_smprintf_free((char *)href);
+	        if (href) {
+	          PR_smprintf_free((char *)href);
+	        }
 	        PR_smprintf_free((char *)info_link);
 	        PR_smprintf_free((char *)log_link);
 	        PR_smprintf_free((char *)repl_link);
-- 
1.7.7.6

--
389-devel mailing list
389-devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/389-devel

Reply via email to