[Libvir] [PATCH] output virsh log to file
Richard W.M. Jones
rjones at redhat.com
Wed May 16 10:52:53 UTC 2007
Actually I had a closer look at this patch, and there are some problems
(thanks to Jim Meyering who pointed these out). For example:
Using sprintf into a fixed size message buffer with no other checks may
cause a buffer overflow:
+ sprintf(msg_buf, "[%d.%02d.%02d %02d:%02d:%02d ",
You should check the return value of write:
+ /* write log */
+ write(logdef.log_fd, msg_buf, msg_len);
You don't need to zero out the stat structure before calling stat:
+ memset(&st, 0x00, sizeof(struct stat));
+ if (stat(logdef.path_buff, &st) == 0) {
What happens if this call fails?
+ rename(logdef.path_buff, bak_new_path);
But my broader point is: What use would this feature be, since you can
capture the output of virsh easily using shell redirection? The Xen
'xm' command doesn't have this feature and I don't know if anyone has
asked for it.
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20070516/8974f3d4/attachment-0001.bin>
More information about the libvir-list
mailing list