FreeBSD Bugzilla – Attachment 237325 Details for
Bug 267032
diff(1) -U and -C with very large number of context may produce incorrect line indicator
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed fix for the integer overflows.
diff-fix-integer-overflow.patch (text/plain), 2.10 KB, created by
Daniel Tameling
on 2022-10-15 09:59:05 UTC
(
hide
)
Description:
proposed fix for the integer overflows.
Filename:
MIME Type:
Creator:
Daniel Tameling
Created:
2022-10-15 09:59:05 UTC
Size:
2.10 KB
patch
obsolete
>diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c >index c9111fe7eaee..cfe330ec54ec 100644 >--- a/usr.bin/diff/diffreg.c >+++ b/usr.bin/diff/diffreg.c >@@ -1071,8 +1071,9 @@ change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d, > */ > print_header(file1, file2); > anychange = 1; >- } else if (a > context_vec_ptr->b + (2 * diff_context) + 1 && >- c > context_vec_ptr->d + (2 * diff_context) + 1) { >+ } else if ((INT_MAX - 1) / 2 >= diff_context && >+ a - context_vec_ptr->b > (2 * diff_context) + 1 && >+ c - context_vec_ptr->d > (2 * diff_context) + 1) { > /* > * If this change is more than 'diff_context' lines from the > * previous change, dump the record and reset it. >@@ -1456,9 +1457,15 @@ dump_context_vec(FILE *f1, FILE *f2, int flags) > > b = d = 0; /* gcc */ > lowa = MAX(1, cvp->a - diff_context); >- upb = MIN(len[0], context_vec_ptr->b + diff_context); >+ if (INT_MAX - diff_context < context_vec_ptr->b) >+ upb = len[0]; >+ else >+ upb = MIN(len[0], context_vec_ptr->b + diff_context); > lowc = MAX(1, cvp->c - diff_context); >- upd = MIN(len[1], context_vec_ptr->d + diff_context); >+ if (INT_MAX - diff_context < context_vec_ptr-> d) >+ upd = len[1]; >+ else >+ upd = MIN(len[1], context_vec_ptr->d + diff_context); > > printf("***************"); > if (flags & (D_PROTOTYPE | D_MATCHLAST)) { >@@ -1559,9 +1566,15 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags) > > b = d = 0; /* gcc */ > lowa = MAX(1, cvp->a - diff_context); >- upb = MIN(len[0], context_vec_ptr->b + diff_context); >+ if (INT_MAX - diff_context < context_vec_ptr->b) >+ upb = len[0]; >+ else >+ upb = MIN(len[0], context_vec_ptr->b + diff_context); > lowc = MAX(1, cvp->c - diff_context); >- upd = MIN(len[1], context_vec_ptr->d + diff_context); >+ if (INT_MAX - diff_context < context_vec_ptr->d) >+ upd = len[1]; >+ else >+ upd = MIN(len[1], context_vec_ptr->d + diff_context); > > printf("@@ -"); > uni_range(lowa, upb);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 267032
: 237325