Re: diff(1) -s option can produce erroneous positives
Crystal Kolipe <[email protected]> Tue, 21 Jul 2026 18:26:31 -0000
| Newsgroups | gmane.os.openbsd.tech |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Jul 20, 2026 at 09:34:39AM -0600, Todd C. Miller wrote:
> This looks reasonable but I would like to see D_INDETERMINATE listed
> in the switch() in print_status() with an empty body, just to make
> it clear that this was not forgotten.
Sure, here is an updated diff with that included:
--- usr.bin/diff/diff.c.dist Thu Apr 16 19:25:12 2026
+++ usr.bin/diff/diff.c Tue Jul 21 13:33:46 2026
@@ -386,6 +386,8 @@
printf("File %s%s is not a regular file or directory and was skipped\n",
path2, entry);
break;
+ case D_INDETERMINATE:
+ break;
}
}
--- usr.bin/diff/diff.h
+++ usr.bin/diff/diff.h
@@ -75,6 +75,7 @@
#define D_MISMATCH2 4 /* path1 was a file, path2 a dir */
#define D_SKIPPED1 5 /* path1 was a special file */
#define D_SKIPPED2 6 /* path2 was a special file */
+#define D_INDETERMINATE 7 /* One or both files could not be opened */
struct excludes {
char *pattern;
--- usr.bin/diff/diffreg.c
+++ usr.bin/diff/diffreg.c
@@ -318,6 +318,7 @@
fstat(fileno(f1), &stb1) == -1) {
warn("%s", file1);
status |= 2;
+ rval = D_INDETERMINATE;
goto closem;
}
} else if (strcmp(file1, "-") == 0)
@@ -328,6 +329,7 @@
if (f1 == NULL) {
warn("%s", file1);
status |= 2;
+ rval = D_INDETERMINATE;
goto closem;
}
@@ -339,6 +341,7 @@
fstat(fileno(f2), &stb2) == -1) {
warn("%s", file2);
status |= 2;
+ rval = D_INDETERMINATE;
goto closem;
}
} else if (strcmp(file2, "-") == 0)
@@ -349,6 +352,7 @@
if (f2 == NULL) {
warn("%s", file2);
status |= 2;
+ rval = D_INDETERMINATE;
goto closem;
}