From d6177870dd2696501e3b8d3930fd5549d4acaeae Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 3 Mar 2021 15:34:04 +0100 Subject: [PATCH] d: Fix heap-buffer-overflow in checkModFileAlias [PR 99337] The code wrongly assumed memcmp did not read past the mismatch. Reviewed-on: https://github.com/dlang/dmd/pull/12247 gcc/d/ChangeLog: PR d/99337 * dmd/MERGE: Merge upstream dmd a3c9bf422. --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/dmodule.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 690fe40..78b454c 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -7132b3537dc27cb353da75798082ffe7ea3d69a6 +a3c9bf422e7ff54d45846b8c577ee82da4234db1 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/dmodule.c b/gcc/d/dmd/dmodule.c index a2b01f5..ed01858 100644 --- a/gcc/d/dmd/dmodule.c +++ b/gcc/d/dmd/dmodule.c @@ -195,7 +195,7 @@ static void checkModFileAlias(OutBuffer *buf, OutBuffer *dotmods, const char *m = (*ms)[j]; const char *q = strchr(m, '='); assert(q); - if (dotmods->length() <= (size_t)(q - m) && memcmp(dotmods->peekChars(), m, q - m) == 0) + if (dotmods->length() == (size_t)(q - m) && memcmp(dotmods->peekChars(), m, q - m) == 0) { buf->reset(); size_t qlen = strlen(q + 1); -- 2.7.4