Commit 36deff04 introduced a regression due to which virsh is not able
to log to a file - msg_buf was changed from an array to a pointer
without corresponding change to usage of "sizeof()".
Fix regression in virsh logging
Signed-off-by: Supriya Kannery <supriyak@xxxxxxxxxx>
---
tools/virsh.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Index: libvirt/tools/virsh.c
===================================================================
--- libvirt.orig/tools/virsh.c
+++ libvirt/tools/virsh.c
@@ -12257,7 +12257,7 @@ vshOutputLogFile(vshControl *ctl, int lo
*/
gettimeofday(&stTimeval, NULL);
stTm = localtime(&stTimeval.tv_sec);
- snprintf(msg_buf, sizeof(msg_buf),
+ snprintf(msg_buf, MSG_BUFFER,
"[%d.%02d.%02d %02d:%02d:%02d ",
(1900 + stTm->tm_year),
(1 + stTm->tm_mon),
@@ -12265,7 +12265,7 @@ vshOutputLogFile(vshControl *ctl, int lo
(stTm->tm_hour),
(stTm->tm_min),
(stTm->tm_sec));
- snprintf(msg_buf + strlen(msg_buf), sizeof(msg_buf) - strlen(msg_buf),
+ snprintf(msg_buf + strlen(msg_buf), MSG_BUFFER - strlen(msg_buf),
"%s] ", SIGN_NAME);
switch (log_level) {
case VSH_ERR_DEBUG:
@@ -12287,13 +12287,13 @@ vshOutputLogFile(vshControl *ctl, int lo
lvl = LVL_DEBUG;
break;
}
- snprintf(msg_buf + strlen(msg_buf), sizeof(msg_buf) - strlen(msg_buf),
+ snprintf(msg_buf + strlen(msg_buf), MSG_BUFFER - strlen(msg_buf),
"%s ", lvl);
- vsnprintf(msg_buf + strlen(msg_buf), sizeof(msg_buf) - strlen(msg_buf),
+ vsnprintf(msg_buf + strlen(msg_buf), MSG_BUFFER - strlen(msg_buf),
msg_format, ap);
if (msg_buf[strlen(msg_buf) - 1] != '\n')
- snprintf(msg_buf + strlen(msg_buf), sizeof(msg_buf) -
strlen(msg_buf), "\n");
+ snprintf(msg_buf + strlen(msg_buf), MSG_BUFFER -
strlen(msg_buf), "\n");
/* write log */
if (safewrite(ctl->log_fd, msg_buf, strlen(msg_buf)) < 0) {
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list