From 34872fadec608a6305ab9bcdd15592282cb194a5 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 26 Jan 2022 06:40:53 +0100 Subject: pasta: Check for zero d_reclen returned by getdents64() syscall 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(-) (limited to 'pasta.c') 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; -- cgit v1.2.3