[PATCH] Fix overflow of -b switch

Jie Zhang jzhang918@gmail.com
Tue Oct 10 09:47:00 GMT 2006


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

<http://blackfin.uclinux.org/tracker/?func=detail&aid=1746&group_id=18&atid=145>,

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?

Jie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-option-b.diff
Type: text/x-patch
Size: 537 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061010/b0d77829/attachment.bin>


More information about the Gcc-patches mailing list