Patchwork [STABLE] revlog: cache delta base value under -1

login
register
mail settings
Submitter Boris Feld
Date Dec. 31, 2018, 5:38 p.m.
Message ID <38e950b3a3bca863b5e2.1546277915@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/37416/
State Accepted
Headers show

Comments

Boris Feld - Dec. 31, 2018, 5:38 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1546182666 -3600
#      Sun Dec 30 16:11:06 2018 +0100
# Branch stable
# Node ID 38e950b3a3bca863b5e2cabda69f5ae641d581d6
# Parent  f4113489e4d493ffb0aa6c3c58454dc7e3b82e83
# EXP-Topic base-check
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 38e950b3a3bc
revlog: cache delta base value under -1

Such base are invalid so we better report them early.
Yuya Nishihara - Jan. 2, 2019, 12:43 a.m.
On Mon, 31 Dec 2018 18:38:35 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1546182666 -3600
> #      Sun Dec 30 16:11:06 2018 +0100
> # Branch stable
> # Node ID 38e950b3a3bca863b5e2cabda69f5ae641d581d6
> # Parent  f4113489e4d493ffb0aa6c3c58454dc7e3b82e83
> # EXP-Topic base-check
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 38e950b3a3bc
> revlog: cache delta base value under -1

Queued for stable, many thanks.

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -863,6 +863,13 @@  static inline int index_baserev(indexObj
 		    rev, result);
 		return -2;
 	}
+	if (result < -1) {
+		PyErr_Format(
+		    PyExc_ValueError,
+		    "corrupted revlog, revision base out of range: %d, %d",
+		    rev, result);
+		return -2;
+	}
 	return result;
 }