[PATCH] Fix the error in determining the range of file name length

Jan Beulich jbeulich@suse.com
Fri Sep 13 12:31:14 GMT 2024


On 13.09.2024 05:19, jiaying.song.cn@windriver.com wrote:
> From: Jiaying Song <jiaying.song.cn@windriver.com>
> 
> The check condition `(strlen(input) + 2) > NAME_MAX` in the code is
> incorrect because it does not leave enough buffer space. This is
> because, in addition to the `tmp_prefix` generated by appending an "_"
> symbol to the `input`, the generated temporary files also have a suffix
> of `s00000.o`.

I agree 2 is too little for the set of uses of dlltmp(). I'm not sure,
however, whether right here we ought to account for what e.g.
make_one_lib_file() further appends. That also doesn't look to require
18 additional characters in the first place, when we'd really like to
avoid resorting to the alternative naming. So no, ...

> Therefore, the final filename adds 9 extra bytes to the
> `input`. To ensure adequate space, the conditional statement should be
> changed to `if ((strlen(input) + 20) > NAME_MAX)`.

I don't think we should go beyond what's needed in the worst case.

Jan


More information about the Binutils mailing list