[Skiboot] [PATCH v2] libffs: Fix string truncation gcc warning.

Stewart Smith stewart at linux.ibm.com
Wed Mar 20 17:30:25 AEDT 2019


Michal Suchanek <msuchanek at suse.de> writes:
> Use memcpy as other libffs functions do.
>
> Signed-off-by: Michal Suchanek <msuchanek at suse.de>
> ---
>  libflash/libffs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> This also fixes the warning for me and brings the code style in line with the
> rest of the file.
>
> diff --git a/libflash/libffs.c b/libflash/libffs.c
> index 221c2b024c10..82caeb39f890 100644
> --- a/libflash/libffs.c
> +++ b/libflash/libffs.c
> @@ -522,7 +522,7 @@ int ffs_part_info(struct ffs_handle *ffs, uint32_t part_idx,
>  		n = calloc(1, FFS_PART_NAME_MAX + 1);
>  		if (!n)
>  			return FLASH_ERR_MALLOC_FAILED;
> -		strncpy(n, ent->name, FFS_PART_NAME_MAX);
> +		memcpy(n, ent->name, FFS_PART_NAME_MAX);
>  		*name = n;
>  	}
>  	return 0;
> -- 
> 2.20.1

Merged to master as of bef1ddc40813976f0f422ade4a5b9374176ca22a

-- 
Stewart Smith
OPAL Architect, IBM.



More information about the Skiboot mailing list