From a302a19cd2b54d5169b71fd55bc8b2a747cf440a Mon Sep 17 00:00:00 2001 From: Konstantin Germanov Date: Tue, 12 Jul 2022 08:57:41 -0400 Subject: [PATCH] Check if lstat size more that zero --- libntfs-3g/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libntfs-3g/device.c b/libntfs-3g/device.c index c8af5fb7..dbdd039f 100644 --- a/libntfs-3g/device.c +++ b/libntfs-3g/device.c @@ -601,7 +601,7 @@ s64 ntfs_device_size_get(struct ntfs_device *dev, int block_size) * We couldn't figure it out by using a specialized ioctl, * so do lstat on device. */ - if (dev->d_ops->stat(dev, &sbuf) == 0 && S_ISREG(sbuf.st_mode)) { + if (dev->d_ops->stat(dev, &sbuf) == 0 && S_ISREG(sbuf.st_mode) && sbuf.st_size > 512) { ntfs_log_debug("STAT nr bytes = %llu (0x%llx)\n", (unsigned long long)sbuf.st_size, (unsigned long long)sbuf.st_size);