From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 11/22] pasta: Check for zero d_reclen returned by getdents64() syscall Date: Fri, 28 Jan 2022 19:33:46 +0100 Message-ID: <20220128183357.3407606-12-sbrivio@redhat.com> In-Reply-To: <20220128183357.3407606-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5963891693823097683==" --===============5963891693823097683== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Seen on PPC with some older kernel versions: we seemingly have bytes left to read from the returned array of dirent structs, but d_reclen is zero: this, and all the subsequent entries, are not valid. Signed-off-by: Stefano Brivio --- pasta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pasta.c b/pasta.c index bcc1261..3928ad0 100644 --- a/pasta.c +++ b/pasta.c @@ -63,7 +63,7 @@ loop: struct dirent *dp = (struct dirent *)buf; int pos = 0; - while (pos < n) { + while (dp->d_reclen && pos < n) { pid_t pid; errno = 0; -- 2.33.0 --===============5963891693823097683==--