Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154278026
D55108.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55108.id.diff
View Options
diff --git a/contrib/libdiff/include/diff_main.h b/contrib/libdiff/include/diff_main.h
--- a/contrib/libdiff/include/diff_main.h
+++ b/contrib/libdiff/include/diff_main.h
@@ -118,7 +118,6 @@
/* Flags set by file atomizer. */
#define DIFF_ATOMIZER_FOUND_BINARY_DATA 0x00000001
-#define DIFF_ATOMIZER_FILE_TRUNCATED 0x00000002
/* Flags set by caller of diff_main(). */
#define DIFF_FLAG_IGNORE_WHITESPACE 0x00000001
diff --git a/contrib/libdiff/lib/diff_atomize_text.c b/contrib/libdiff/lib/diff_atomize_text.c
--- a/contrib/libdiff/lib/diff_atomize_text.c
+++ b/contrib/libdiff/lib/diff_atomize_text.c
@@ -141,6 +141,7 @@
bool embedded_nul = false;
unsigned int array_size_estimate = d->len / 50;
unsigned int pow2 = 1;
+ int ret = DIFF_RC_OK;
while (array_size_estimate >>= 1)
pow2++;
@@ -152,13 +153,14 @@
sigaction(SIGBUS, &act, &oact);
if (sigsetjmp(diff_data_signal_env, 0) > 0) {
/*
- * The file was truncated while we were reading it. Set
- * the end pointer to the beginning of the line we were
- * trying to read, adjust the file length, and set a flag.
+ * The file was truncated while we were reading it, or an
+ * I/O error occurred. Set the end pointer to the
+ * beginning of the line we were trying to read, adjust
+ * the file length, and set the return value to an error.
*/
end = pos;
d->len = end - d->data;
- d->atomizer_flags |= DIFF_ATOMIZER_FILE_TRUNCATED;
+ ret = EIO;
}
while (pos < end) {
const uint8_t *line_start = pos, *line_end = pos;
@@ -203,7 +205,7 @@
if (embedded_nul)
d->atomizer_flags |= DIFF_ATOMIZER_FOUND_BINARY_DATA;
- return DIFF_RC_OK;
+ return ret;
}
static int
diff --git a/lib/libdiff/tests/libdiff_test.c b/lib/libdiff/tests/libdiff_test.c
--- a/lib/libdiff/tests/libdiff_test.c
+++ b/lib/libdiff/tests/libdiff_test.c
@@ -45,10 +45,9 @@
rewind(f);
ATF_REQUIRE(truncate(fn, size / 2) == 0);
ATF_REQUIRE((p = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fileno(f), 0)) != MAP_FAILED);
- ATF_REQUIRE(diff_atomize_file(&d, &cfg, f, p, size, 0) == 0);
+ ATF_REQUIRE(diff_atomize_file(&d, &cfg, f, p, size, 0) == EIO);
ATF_REQUIRE((size_t)d.len <= size / 2);
ATF_REQUIRE((size_t)d.len >= size / 2 - sizeof(line));
- ATF_REQUIRE(d.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED);
}
ATF_TC_CLEANUP(diff_atomize_truncated, tc)
{
diff --git a/usr.bin/diff/diffreg_new.c b/usr.bin/diff/diffreg_new.c
--- a/usr.bin/diff/diffreg_new.c
+++ b/usr.bin/diff/diffreg_new.c
@@ -223,14 +223,10 @@
rc = D_ERROR;
goto done;
}
- if (left.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED)
- warnx("%s truncated", file1);
if (diff_atomize_file(&right, cfg, f2, (uint8_t *)str2, st2.st_size, diff_flags)) {
rc = D_ERROR;
goto done;
}
- if (right.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED)
- warnx("%s truncated", file2);
result = diff_main(cfg, &left, &right);
if (result->rc != DIFF_RC_OK) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 28, 1:41 PM (19 h, 52 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32282180
Default Alt Text
D55108.id.diff (2 KB)
Attached To
Mode
D55108: libdiff: Simplify truncation detection
Attached
Detach File
Event Timeline
Log In to Comment