Message ID | 20181121142753.25523-1-bradleyb@fuzziesquirrel.com |
---|---|
State | Rejected |
Headers | show |
Series | libffs: fix gcc8 stringop-truncation warnings | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | master/apply_patch Successfully applied |
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot | success | Test snowpatch/job/snowpatch-skiboot on branch master |
diff --git a/libflash/libffs.c b/libflash/libffs.c index 221c2b02..816153d3 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); + strncpy(n, ent->name, FFS_PART_NAME_MAX +1); *name = n; } return 0;
Copy the null byte too in this copy operation to avoid the following warning: | libflash/libffs.c: In function 'ffs_part_info': | libflash/libffs.c:525:3: error: 'strncpy' output may be truncated copying 15 bytes from a string of length 15 [-Werror=stringop-truncation] | strncpy(n, ent->name, FFS_PART_NAME_MAX); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> --- libflash/libffs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)