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

Re: [libvirt] [PATCH v2] udev: fix crash in libudev logging



On 06/14/2013 11:18 AM, Michal Privoznik wrote:
> On 14.06.2013 10:53, Guannan Ren wrote:
>> On 06/13/2013 09:56 PM, Ján Tomko wrote:
>>> +    virBuffer buf = VIR_BUFFER_INITIALIZER;
>>> +    const char *format = NULL;
>>> +
>>> +    virBufferAdd(&buf, fmt, -1);
>>> +    virBufferTrim(&buf, "\n", -1);
>>> +
>>
>>           We need a virBufferError checking here before formatting into
>> a string.

virBufferContentAndReset already checks for the error and returns NULL if
there was one. The only possible error here is ENOMEM.

> 
> In which case we want to got with fmt as provided.
> 
> Michal
> 

If we aren't going to report the buffer error, I think checking format for
NULL should be enough.

I'll squash this in before pushing:

diff --git a/src/node_device/node_device_udev.c
b/src/node_device/node_device_udev.c
index b462549..bb58415 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -374,10 +374,9 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,

     format = virBufferContentAndReset(&buf);

-    if (format)
-        virLogVMessage(VIR_LOG_FROM_LIBRARY,
-                       virLogPriorityFromSyslog(priority),
-                       file, line, fn, NULL, format, args);
+    virLogVMessage(VIR_LOG_FROM_LIBRARY,
+                   virLogPriorityFromSyslog(priority),
+                   file, line, fn, NULL, format ? format : fmt, args);

     VIR_FREE(format);
 }


Jan


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