From 3030e7b5acdf7579d25dbec4827ab1ebf61e4480 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 1 Mar 2022 16:00:40 +0100 Subject: vtysh: fix coverity issues in live-log code Signed-off-by: David Lamparter --- vtysh/vtysh.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'vtysh/vtysh.c') diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 12ab4c2eb..f8c6a1fc1 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -218,9 +218,9 @@ static ssize_t vtysh_client_receive(struct vtysh_client *vclient, char *buf, do { ret = recvmsg(vclient->fd, &mh, 0); - if (ret < 0 && (errno == EINTR || errno == EAGAIN)) - continue; - } while (false); + if (ret >= 0 || (errno != EINTR && errno != EAGAIN)) + break; + } while (true); if (cmh->cmsg_len == CMSG_LEN(sizeof(int))) { int fd; @@ -3592,7 +3592,7 @@ static void vtysh_log_print(struct vtysh_client *vclient, struct tm tm; char ts_buf[32]; - if (hdr->prio > array_size(visual_prios)) + if (hdr->prio >= array_size(visual_prios)) vis = &visual_prios[LOG_CRIT]; else vis = &visual_prios[hdr->prio]; @@ -3657,6 +3657,8 @@ static void vtysh_log_read(struct thread *thread) if (ret <= 0) { struct timespec ts; + buf.text[0] = '\0'; /* coverity */ + if (ret != 0) snprintfrr(buf.text, sizeof(buf.text), "log monitor connection error: %m"); -- cgit v1.2.3