Re: [libvirt] [PATCH] Fix openlog() ident usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 20, 2009 at 08:36:27PM +0100, Daniel Veillard wrote:
> On Tue, Jan 20, 2009 at 11:14:03AM -0800, john.levon@xxxxxxx wrote:
> > It cannot be freed, as it's used by reference in the syslog code, at
> > least on Solaris.
> 
>   The requirement is apparently not present on Linux, sorry :-)
> 
>   I would prefer to keep the reference around and not leak it for
> example on reloads

  Another version with an extra strdup but making clearer what
the change do and fixing the closelog/free order,

 if tested positively please apply, thanks !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
Index: src/logging.c
===================================================================
RCS file: /data/cvs/libxen/src/logging.c,v
retrieving revision 1.6
diff -u -r1.6 logging.c
--- src/logging.c	15 Jan 2009 19:56:05 -0000	1.6
+++ src/logging.c	20 Jan 2009 21:15:20 -0000
@@ -626,15 +626,27 @@
     return(len);
 }
 
+static char *current_ident = NULL;
+
 static void virLogCloseSyslog(void *data ATTRIBUTE_UNUSED) {
     closelog();
+    VIR_FREE(current_ident);
 }
 
 static int virLogAddOutputToSyslog(int priority, const char *ident) {
-    openlog(ident, 0, 0);
+    /*
+     * ident need to be kept around on Solaris
+     */
+    VIR_FREE(current_ident);
+    current_ident = strdup(ident);
+    if (current_ident == NULL)
+        return(-1);
+
+    openlog(current_ident, 0, 0);
     if (virLogDefineOutput(virLogOutputToSyslog, virLogCloseSyslog, NULL,
                            priority, 0) < 0) {
         closelog();
+        VIR_FREE(current_ident);
         return(-1);
     }
     return(0);
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]