]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wall: make sure unsigned variable not underflow
authorKarel Zak <kzak@redhat.com>
Mon, 29 Apr 2024 12:55:16 +0000 (14:55 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 2 May 2024 08:56:26 +0000 (10:56 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/ttymsg.c

index faa0344feb349dada2b8fdfc870ef4a79d33b55c..ef7e35899f63fbc8bc4da7600d66bb2b42fe7ab2 100644 (file)
@@ -123,7 +123,7 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
                                    iovcnt * sizeof(struct iovec));
                                iov = localiov;
                        }
-                       for (cnt = 0; wret >= (ssize_t) iov->iov_len; ++cnt) {
+                       for (cnt = 0; wret >= (ssize_t) iov->iov_len && iovcnt > 0; ++cnt) {
                                wret -= iov->iov_len;
                                ++iov;
                                --iovcnt;