d: Fix heap-buffer-overflow in checkModFileAlias [PR 99337]
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 3 Mar 2021 14:34:04 +0000 (15:34 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 3 Mar 2021 17:51:08 +0000 (18:51 +0100)
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
gcc/d/dmd/dmodule.c

index 690fe40..78b454c 100644 (file)
@@ -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.
index a2b01f5..ed01858 100644 (file)
@@ -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);