On Sat, Jan 09, 2021 at 12:05:31AM -0800, William Ahern wrote:
<snip>
> Interestingly, DragonflyBSD and FreeBSD already do it this way[3][4], yet I
> can confirm FreeBSD still has the problem. (DragonflyBSD has nearly
> identical code.) But that implementation duplicates the short-circuit, along
> with the bug of not accounting for skip1 and skip2, in cmp.c as part of
> implementing the -z flag[5]:
> 
>       if (special)
>               c_special(fd1, file1, skip1, fd2, file2, skip2);
>       else {
>               if (zflag && sb1.st_size != sb2.st_size) {
>                       if (!sflag)
>                               (void) printf("%s %s differ: size\n",
>                                   file1, file2);
>                       exit(DIFF_EXIT);
>               }
>               c_regular(fd1, file1, skip1, sb1.st_size,
>                   fd2, file2, skip2, sb2.st_size);
>       }
>       exit(0);
> 
> It appears that the June 20, 2000 fix to the short-circuit in regular.c
> wasn't recognized during the July 14, 2000 -z feature addition.[6][7]

Note that zflag is set with sflag earlier in FreeBSD's regular.c:

                case 's':               /* silent run */
                        sflag = 1;
                        zflag = 1;
                        break;

Reply via email to