From e53339d2dc48207afa94f48d24c3d2aba979b467 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 28 Feb 2002 04:28:07 +0000 Subject: [PATCH] (diff_2_files): Avoid arithmetic overflow in buffer size calculation. --- src/analyze.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/analyze.c b/src/analyze.c index 8965744..c83b40f 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1,7 +1,7 @@ /* Analyze file differences for GNU DIFF. - Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001 Free - Software Foundation, Inc. + Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002 + Free Software Foundation, Inc. This file is part of GNU DIFF. @@ -853,7 +853,9 @@ diff_2_files (struct comparison *cmp) size_t buffer_size = buffer_lcm (sizeof (word), buffer_lcm (STAT_BLOCKSIZE (cmp->file[0].stat), - STAT_BLOCKSIZE (cmp->file[1].stat))); + STAT_BLOCKSIZE (cmp->file[1].stat), + PTRDIFF_MAX - 1), + PTRDIFF_MAX - 1); for (f = 0; f < 2; f++) cmp->file[f].buffer = xrealloc (cmp->file[f].buffer, buffer_size);