[gcc r9-9262] d: Fix heap-buffer-overflow in checkModFileAlias [PR 99337]
Iain Buclaw
ibuclaw@gcc.gnu.org
Wed Mar 3 21:38:03 GMT 2021
https://gcc.gnu.org/g:03d7b32e0ebf15047a97d3f27faf5771ecf79a03
commit r9-9262-g03d7b32e0ebf15047a97d3f27faf5771ecf79a03
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 3 15:34:04 2021 +0100
d: Fix heap-buffer-overflow in checkModFileAlias [PR 99337]
The code wrongly assumed memcmp did not read past the mismatch.
gcc/d/ChangeLog:
PR d/99337
* dmd/dmodule.c (checkModFileAlias): Don't read past buffer in
comparison.
(cherry picked from commit d6177870dd2696501e3b8d3930fd5549d4acaeae)
Diff:
---
gcc/d/dmd/dmodule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/d/dmd/dmodule.c b/gcc/d/dmd/dmodule.c
index 1f6fd9f10a6..2779f627b8d 100644
--- a/gcc/d/dmd/dmodule.c
+++ b/gcc/d/dmd/dmodule.c
@@ -202,7 +202,7 @@ static void checkModFileAlias(OutBuffer *buf, OutBuffer *dotmods,
const char *m = (*ms)[j];
const char *q = strchr(m, '=');
assert(q);
- if (dotmods->offset <= (size_t)(q - m) && memcmp(dotmods->peekString(), m, q - m) == 0)
+ if (dotmods->offset == (size_t)(q - m) && memcmp(dotmods->peekString(), m, q - m) == 0)
{
buf->reset();
size_t qlen = strlen(q + 1);
More information about the Gcc-cvs
mailing list