Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 02 Jan 2024 21:46:28 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 276043] md5(1) et al are broken when reading the last argument because of capsicum(4) code
Message-ID:  <bug-276043-227-kbvcUY3FOt@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-276043-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-276043-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276043

Ricardo Branco <rbranco@suse.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|fread(3) is truncated when  |md5(1) et al are broken
                   |reading from                |when reading the last
                   |pseudo-filesystems          |argument because of
                   |                            |capsicum(4) code

--- Comment #2 from Ricardo Branco <rbranco@suse.com> ---
I figured out the problematic code at:

```
                        /*
                         * XXX Enter capability mode on the last argv file.
                         * When a casper file service or other approach is
                         * available, switch to that and enter capability m=
ode
                         * earlier.
                         */
                        if (*(argv + 1) =3D=3D NULL) {
#ifdef HAVE_CAPSICUM
                                cap_rights_init(&rights, CAP_READ, CAP_FSTA=
T);
                                if (caph_rights_limit(fileno(f), &rights) <=
 0
||
                                    caph_enter() < 0)
                                        err(1, "capsicum");
#endif
                        }
```

So md5 works if I pass /dev/null as the last argument:

$ md5 /compat/linux/proc/cpuinfo
MD5 (/compat/linux/proc/cpuinfo) =3D 36966b53dc9e57113b2b7637d8b51720
$ md5 /compat/linux/proc/cpuinfo /dev/null
MD5 (/compat/linux/proc/cpuinfo) =3D 142e18c701aa58b0e691920e2bf98e56
MD5 (/dev/null) =3D d41d8cd98f00b204e9800998ecf8427e

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-276043-227-kbvcUY3FOt>