ndctl/namespace.c: fix unchecked return value from uuid_parse()
Vishal Verma
maintainerPATCH 1/1 ndctl/namespace.c: fix unchecked return value from uuid_parse()
Static analysis reports that write_pfn_sb() neglects to check the return value from uuid_parse as is done elsewhere. Since the uuid being parsed comes from the user, check for failure, and return an EINVAL if so.
Cc Dan Williams <[email protected]>
Signed-off-by Vishal Verma <[email protected]>
--- ndctl/namespace.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
ndctl/namespace.c +10 -6
@@ -1869,15 +1869,19 @@ static int write_pfn_sb(int fd, unsigned long long size, const char *sig, npfns =PHYS_PFN (size -SZ_8K ); pfn_align =parse_size64 (param.align); align =max (pfn_align,SUBSECTION_SIZE ); -if (param.uuid) -uuid_parse (param.uuid, uuid); -else +if (param.uuid) { +if (uuid_parse (param.uuid, uuid)) +return -EINVAL ; + }else {uuid_generate (uuid); + } -if (param.parent_uuid) -uuid_parse (param.parent_uuid, parent_uuid); -else +if (param.parent_uuid) { +if (uuid_parse (param.parent_uuid, parent_uuid)) +return -EINVAL ; + }else {memset (parent_uuid,0 ,sizeof (uuid_t)); + }if (strcmp (param.map,"dev" ) ==0 ) mode =PFN_MODE_PMEM ;
---
base-commit: 26d9ce3351361631677e2cae933e3641540fa807
change-id: 20230502-vv-coverity-d3a9dc40abd6
Best regards,
Signature · 1 line
Vishal Verma <[email protected]>
Quoted 3 lines · Vishal Verma
Static analysis reports that
write_pfn_sb()neglects to check the return value fromuuid_parseas is done elsewhere. Since the uuid being parsed comes from the user, check for failure, and return an EINVAL if so.
Looks good to me, you can add:
Reviewed-by Dan Williams <[email protected]>