From nobody Sun Dec 31 20:59:27 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T3BLm1328z55HM7 for ; Sun, 31 Dec 2023 20:59:28 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T3BLl5f45z3W4y for ; Sun, 31 Dec 2023 20:59:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704056367; a=rsa-sha256; cv=none; b=JSCe8q3Gs9ecXbYXX10pCvJZ3AD3DGIPJr+EU8aelAnTVvBeBfSfb6/mUa6Dmjc2w5DrWT //Q99EYZkf7NnvJHa94rngl3LYEQLvAxe+G/t1oj4rMUSt/OaDUJGHNGBnw8V/o/0lRYw/ liEp9OVUj2eecWW1s2XL18CmzyxsSxvgxfKmgfh5v3sv5R3BIV8vR+HVP6V6ZWQRudAvVr rP4plOCSKxYxIehgevcktFmHAQsXAMbfwU2Av0aLBSq+cktWWF6QEhFQtjBbLmx6zeOkIZ VfWo5R3HK9kh6M1/QsNEu/0bwTZJm02ewKvaKy6HzLfGQRduL0Ho+fbv9bk1Bg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704056367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ds6DXtBJwk8qPcrcT0Y9+aCmfGwschx+BX9yUIRRO2g=; b=gEwsOjMcbxY94LjGyO6BVfhZYHCvPXVULZ6v/TBfEEDHF5qt2SFQYAZ9fJU+MSl6Uv5fAt vTK/gFLWYdSlVEWGQDk0jLvZoRjxkzYHkVMkZv4jeRK7biDRP+vC/jevTl2gm3EYAaGxeJ d5X0pSaWblu94bVr4yvKEhVjdCIt0b2+VteaFKbdAd6yWND6/14IBOJlDm4yfFOgPNLeTm hsZkFKczev24FXJk7c7hSFbEY+qAfGnb7ZeXuUhnEtbdd0QThS88gVCRHd9iTbIymg0hzR B8gk1IRuoc4lDCPIvVbTo8veBiLM05z2wq/ar+qJkZkqrehLr19Xu5dgFZWKbw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T3BLl4bRQzq6L for ; Sun, 31 Dec 2023 20:59:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 3BVKxRuj056378 for ; Sun, 31 Dec 2023 20:59:27 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 3BVKxRoV056377 for bugs@FreeBSD.org; Sun, 31 Dec 2023 20:59:27 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 276043] fread(3) is truncated when reading from pseudo-filesystems Date: Sun, 31 Dec 2023 20:59:27 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 14.0-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: rbranco@suse.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276043 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: bugs@FreeBSD.org Reporter: rbranco@suse.com I was looking why the output of `md5 /compat/linux/proc/cpuinfo` is differe= nt from `cat /compat/linux/proc/cpuinfo | md5` and came across this code in sbin/md5/md5.c: ``` char block[4096]; ... while ((len =3D 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=20 ... read(3,"processor\t: 0\nvendor_id\t: Gen"...,4096) =3D 3549 (0xddd) ... ``` It obviously affects all tools using libc when comparing the output of wc v= s. GNU wc: ``` $ wc -m /compat/linux/proc/cpuinfo 3549 /compat/linux/proc/cpuinfo $ gwc -m /compat/linux/proc/cpuinfo 3685 /compat/linux/proc/cpuinfo ``` --=20 You are receiving this mail because: You are the assignee for the bug.=