Re: [PATCH 5/6] Add an an internal API for emergency dump of debug buffer

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

 



On 03/04/2011 03:30 AM, Daniel Veillard wrote:
> virLogEmergencyDumpAll() allows to dump the content of the
> debug buffer from within a signal handler. It saves to all
> log file or stderr if none is found
> * src/util/logging.h src/util/logging.c: add the new API
>   and cleanup the old virLogDump code
> * src/libvirt_private.syms: exports it as a private symbol

> 
> +void
> +virLogEmergencyDumpAll(int signum) {
> +    int ret = 0, len;
> +    char buf[100];
> +
> +    if (virLogLen == 0)
> +        return;
>  
> -    if ((virLogLen == 0) || (f == NULL))
> -        return 0;
>      virLogLock();

Is virLogLock async-signal-safe?

> +    snprintf(buf, sizeof(buf) - 1,
> +             "Caught signal %d, dumping internal log buffer:\n", signum);

snprintf is _not_ safe; it can call malloc.  We probably ought to use a
manual decimal-to-string conversion loop instead.

> +    buf[sizeof(buf) - 1] = 0;
> +    virLogDumpAllFD(buf, strlen(buf));
> +    snprintf(buf, sizeof(buf) - 1, "\n\n    ====== start of log =====\n\n");

Why snprintf here, rather than strcpy?

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]