On 2026/3/3 03:01, David Scott wrote:
On my Mac I saw a CPU spin which looked like this:
```
Call graph:
     2192 Thread_132504   DispatchQueue_1: com.apple.main-thread  (serial)
       2192 start  (in dyld) + 6992  [0x185bcbda4]
         2192 main  (in mkfs.erofs) + 7916  [0x10253a6d0]
           2192 tarerofs_parse_tar  (in mkfs.erofs) + 5492  [0x102551d48]
             2187 tarerofs_write_file_data  (in mkfs.erofs) + 140  [0x102551fe0]
             + 2187 write  (in libsystem_kernel.dylib) + 8  [0x185f47834]
             4 tarerofs_write_file_data  (in mkfs.erofs) + 116  [0x102551fc8]
             + 4 erofs_iostream_read  (in mkfs.erofs) + 16,36,...  
[0x10254fa28,0x10254fa3c,...]
             1 tarerofs_write_file_data  (in mkfs.erofs) + 140  [0x102551fe0]
```

The input stream was closed prematurely, so the reads returned 0 (EOF),
which wasn't considered an error.

Treat return of 0 (EOF) as an error.

Reproduce by:
```
dd if=/dev/zero bs=1024 count=4 2>/dev/null > /tmp/testfile
COPYFILE_DISABLE=1 tar cf - -C /tmp testfile | head -c 2048 > /tmp/truncated.tar
./mkfs/mkfs.erofs --tar=f output.erofs < /tmp/truncated.tar
```
Before the patch this will hang, after it should fail as expected.

(COPYFILE_DISABLE tells mac to avoid putting extra stuff in the tar)

Closes: https://github.com/erofs/erofs-utils/issues/43
Signed-off-by: David Scott <[email protected]>

LGTM, will apply.

Thanks,
Gao Xiang

Reply via email to