Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH 0/1] Replace strncpy w/ memcpy to avoid -Wstringop-truncation



> 2019/03/23 19:43, Wesley Schwengle <wesleyschwengle@xxxxxxxxx> wrote:
> 
> Another warning that I saw when building from git on Debian with cc
> 8.3.0 was this one.
> 
> params.c: In function ‘assignstrvalue.part.16’:
> params.c:2588:17: warning: ‘strncpy’ output truncated before terminating
> nul copying as many bytes from a string as its length [-Wstringop-truncation]
> strncpy(z + v->start, val, vlen);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> params.c:2571:20: note: length computed here
> vlen = strlen(val);
> ^~~~~~~~~~~
> 
> In this case I replaces strncpy with memcpy().

Thanks. I've pushed your patch.

The last null byte of val is never copied here so using memcpy()
is more appropriate, I think.



Messages sorted by: Reverse Date, Date, Thread, Author