Skip to contentSkip to conversation

Minor coverity defect fix - CID 1125928 In set_file_xattrs: Dereference of an explicit null value

PATCH In review Harinath Nampally 2 participants 2 messages Nov 16, 2016 – Nov 30, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Minor coverity defect fix - CID 1125928 In set_file_xattrs: Dereference of an explicit null value

---
 cmds-restore.c | 3 +++
 1 file changed, 3 insertions(+)
cmds-restore.c +3 -0
index a8c67a5..6c2ea8a 100644
@@ -509,6 +509,9 @@ static int set_file_xattrs(struct btrfs_root *root, u64 inode,
 
 		while (cur < total_len) {
 			len = btrfs_dir_name_len(leaf, di);
+                        if (len == 0) {
+                                goto out;
+                        }
 			if (len > name_len) {
 				free(name);
 				name = (char *) malloc(len + 1);
Signature · 1 line
2.7.4
#1 lore raw

Hi,

this patch lacks basic formatting requirements, this has been
extensively documented eg. here https://btrfs.wiki.kernel.org/index.php/Developer's_FAQ .

Besides the formalities, I'm missing what's the change rationale. It deals with a strange case when the xattr name length is 0, which is unexpected and should not be handled silently. Next I'm not sure if bailing out of the function is right, there are more items to process. Best if we could skip the damaged ones but still continue.