Patchwork D1876: bdiff: Handle the possibility of an integer overflow when allocating

login
register
mail settings
Submitter phabricator
Date Jan. 17, 2018, 9:36 p.m.
Message ID <differential-rev-PHID-DREV-tqhl6kl5hp55xeufl2gf-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26827/
State Superseded
Headers show

Comments

phabricator - Jan. 17, 2018, 9:36 p.m.
alex_gaynor created this revision.
alex_gaynor added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  alloc-overflow (bookmark) on default (branch)

REVISION DETAIL
  https://phab.mercurial-scm.org/D1876

AFFECTED FILES
  mercurial/bdiff.c
  mercurial/tagmerge.py

CHANGE DETAILS




To: alex_gaynor, durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 17, 2018, 9:38 p.m.
alex_gaynor abandoned this revision.
alex_gaynor added a comment.


  Closing in favor of https://phab.mercurial-scm.org/D1877

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1876

To: alex_gaynor, durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -269,4 +269,3 @@ 
     writemergedtags(fcd, mergedtags)
     ui.note(_('.hgtags merged successfully\n'))
     return False, 0
-
diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -41,7 +41,7 @@ 
 	if (p == plast)
 		i++;
 
-	*lr = l = (struct bdiff_line *)malloc(sizeof(struct bdiff_line) * i);
+	*lr = l = (struct bdiff_line *)calloc(i, sizeof(struct bdiff_line));
 	if (!l)
 		return -1;