]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: fix coverity issues in live-log code
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 1 Mar 2022 15:00:40 +0000 (16:00 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 1 Mar 2022 15:00:56 +0000 (16:00 +0100)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
vtysh/vtysh.c

index 12ab4c2eba83d864050078260a1c20e3337a7ae9..f8c6a1fc1d4427b08f1ca5ce8b56468a55459fd4 100644 (file)
@@ -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");