This is the mail archive of the
mailing list for the GCC project.
[PATCH] Fix overflow of -b switch
- From: "Jie Zhang" <jzhang918 at gmail dot com>
- To: "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 10 Oct 2006 16:52:46 +0800
- Subject: [PATCH] Fix overflow of -b switch
process_command () scans command line twice. The first time it just
counts how many switches. Then the switches vector is created
according to the count. The second time it copies the text of each
switch and stores a pointer to the copy in the vector of switches.
Currently, the first scan does not count -b if its argument has no
dash. So the switches vector has no enough space for all switches and
is overflowed when the second scan tries to store the pointers.
Mike Frysinger observed a crash of Blackfin GCC 4.1.1 on amd64 host.
The original bug report is
which I believe is caused by the overflow.
This patch fixes it by treating such -b switch as normal switch.
Regression test is going on. Is it OK?
* gcc.c (process_command): Treat -b as normal switch if its argument
has no dash.
--- gcc.c (revision 117594)
+++ gcc.c (working copy)
@@ -3744,7 +3744,10 @@
- if (NULL == strchr(argv[i] + 2, '-')) break;
+ if (NULL == strchr(argv[i] + 2, '-'))
+ goto normal_switch;
+ /* Fall through. */
fatal ("'-%c' must come at the start of the command line", c);