https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276043

            Bug ID: 276043
           Summary: fread(3) is truncated when reading from
                    pseudo-filesystems
           Product: Base System
           Version: 14.0-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: [email protected]
          Reporter: [email protected]

I was looking why the output of `md5 /compat/linux/proc/cpuinfo` is different
from `cat /compat/linux/proc/cpuinfo | md5` and came across this code in
sbin/md5/md5.c:

```
        char block[4096];
..
        while ((len = fread(block, 1, sizeof(block), f)) > 0) {
```

```

The issue is a truncated read as confirmed by truss and GNU wc:

```
$ sudo truss md5 /compat/linux/proc/cpuinfo 
..
read(3,"processor\t: 0\nvendor_id\t: Gen"...,4096) = 3549 (0xddd)
..
```

It obviously affects all tools using libc when comparing the output of wc vs.
GNU wc:

```
$ wc -m /compat/linux/proc/cpuinfo
    3549 /compat/linux/proc/cpuinfo
$ gwc -m /compat/linux/proc/cpuinfo
3685 /compat/linux/proc/cpuinfo
```

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to