This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Prevent out of bound access for multilib_options
- From: Kito Cheng <kito at 0xlab dot org>
- To: gcc-patches at gcc dot gnu dot org, jakub at redhat dot com, rguenther at suse dot de, rsandifo at linux dot vnet dot ibm dot com
- Date: Wed, 9 Apr 2014 22:00:38 +0800
- Subject: [PATCH] Prevent out of bound access for multilib_options
- Authentication-results: sourceware.org; auth=none
`q` will out of bound access if `*q` already reach the end of
multilib_options, so check it before increment to prevent condition
check part out of bound access.
btw, this bug is detected by address sanitizer.
2014-04-09 Kito Cheng <kito@0xlab.org>
* gcc.c (used_arg): Prevent out of bound access for multilib_options.
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 5cb485a..c8ab7d6 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -7490,7 +7490,7 @@ used_arg (const char *p, int len)
{
const char *r;
- for (q = multilib_options; *q != '\0'; q++)
+ for (q = multilib_options; *q != '\0'; *q && q++)
{
while (*q == ' ')
q++;