This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] gas/config/tc-tic4x.c: Let insn name full use its space and always zero terminated
- From: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 24 Nov 2014 14:00:59 +0800
- Subject: Re: [PATCH] gas/config/tc-tic4x.c: Let insn name full use its space and always zero terminated
- Authentication-results: sourceware.org; auth=none
- References: <546A187C dot 4000202 at gmail dot com> <20141124032749 dot GG4477 at bubble dot grove dot modra dot org>
On 11/24/14 11:27, Alan Modra wrote:
> On Mon, Nov 17, 2014 at 11:47:08PM +0800, Chen Gang wrote:
>> strncpy() can not be sure of insn name must be zero terminated, so need
>> set it explicitly.
>
> OK.
>
>> At present, insn name is only used in tic4x_insn_check() which only test
>> insn name within 9 chars explicitly. So it is harmless to use full space
>> of insn name for strncpy().
>
> Not OK. You missed noticing that md_assemble is called recursively
> for parallel instructions, and does strcat (insn->name, "_"). So
> space must be reserved.
>
Oh sorry, it is my typo issue, it should be:
"... insn name is only useful in tic4x_insn_check() ..."
And for me, we also need strncat() instead of the strcat() (excuse me
for not noticing about it in the original fixing strncat issue patch):
strcat (insn->name, "_");
strncat (insn->name, str, TIC4X_NAME_MAX - 1 - strlen (insn->name));
Thanks.
--
Chen Gang
Open, share, and attitude like air, water, and life which God blessed