On 06/12/2025 08:27, Giorgi Tchankvetadze wrote:
When using 'cmp -n NUM' without '-l', the program would incorrectly
continue comparing after finding the first difference, printing
multiple 'differ' lines instead of just one.
The bug was in line 144: 'if (opt)' checked if ANY option was set
(including -n), causing it to continue. It should only continue
for -l (verbose) mode: 'if (opt & CMP_OPT_l)'.
The patch looks correct to me aside from one small detail, though it's
worth noting this was correct when it was written and -l and -s were the
only options. It became a bug when -n was added.
- if (opt) { /* This must be -l since not
-s. */
+ if (opt & CMP_OPT_l) { /* This must be -l
since not -s. */
This comment no longer applies and can be removed.
Cheers,
Harald van Dijk
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox