Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jan 2021 16:53:19 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 252614] /usr/bin/diff : BUG: Incorrectly displaying files as duplicates (includes fix)
Message-ID:  <bug-252614-227@https.bugs.freebsd.org/bugzilla/>

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

            Bug ID: 252614
           Summary: /usr/bin/diff : BUG: Incorrectly displaying files as
                    duplicates (includes fix)
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: jamie@catflap.org

Created attachment 221499
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D221499&action=
=3Dedit
patch to fix diff bug

When diff hits certain access errors, function diffreg() shows the error
message, and then returns to the calling function, which calls print_status=
()
with the return value.

However, in these cases, the return value isn't changed from the initial
default value of D_SAME.

Normally, print_status() with a value of D_SAME does nothing, so this works=
 out
ok, however, if the "-s" flag is set, a message is displayed showing
identicality:

case D_SAME:
                if (sflag)
                        printf("Files %s%s and %s%s are identical\n",=20=20=
=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20
            path1, entry, path2, entry);
                break;

This then produces such results as:

% diff  -s /COPYRIGHT /var/run/rpcbind.sock
diff: /var/run/rpcbind.sock: Operation not supported
Files /COPYRIGHT and /var/run/rpcbind.sock are identical

% diff  -s /COPYRIGHT /etc/master.passwd
diff: /etc/master.passwd: Permission denied
Files /COPYRIGHT and /etc/master.passwd are identical

A quick fix would be to alter the above line:

   if (sflag)

to

   if (sflag && status & 2)

A less hacky fix is attached as a patch. It creates a D_ERROR status which =
is
returned in such cases, and print_status() then deals with that status
seperately from D_SAME.

--=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-252614-227>